|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mycore.common.MCRUtils
public class MCRUtils
This class represent a general set of external methods to support the programming API.
| Field Summary | |
|---|---|
static char |
COMMAND_AND
|
static char |
COMMAND_OR
|
static char |
COMMAND_XOR
|
| Constructor Summary | |
|---|---|
MCRUtils()
|
|
| Method Summary | ||
|---|---|---|
static String |
arrayToString(Object[] objArray,
String seperator)
|
|
static boolean |
copyReader(Reader source,
Writer target)
Copies all content read from the given input stream to the given output stream. |
|
static boolean |
copyStream(InputStream source,
OutputStream target)
Copies all content read from the given input stream to the given output stream. |
|
static GregorianCalendar |
covertDateToGregorianCalendar(String indate)
The methode convert the input date string to the GregorianCalendar. |
|
static String |
covertDateToISO(String indate)
The methode convert the input date string to the ISO output string. |
|
static
|
cutArrayList(ArrayList<? extends T> arrayin,
int maxitems)
The method cut an ArrayList for a maximum of items. |
|
static ArrayList<String> |
getAllDirectoryNames(File basedir)
The method return a list of all directory names under the given directory and subdirectories of itself. |
|
static ArrayList<String> |
getAllDirectoryNames(File basedir,
String path)
The method return a list of all directory names under the given directory and subdirectories of itself. |
|
static ArrayList<String> |
getAllFileNames(File basedir)
The method return a list of all file names under the given directory and subdirectories of itself. |
|
static ArrayList<String> |
getAllFileNames(File basedir,
String path)
The method return a list of all file names under the given directory and subdirectories of itself. |
|
static byte[] |
getByteArray(Document jdom)
This method convert a JDOM tree to a byte array. |
|
static String[] |
getStringArray(Object[] objects)
Converts an Array of Objects to an Array of Strings using the toString() method. |
|
static String[] |
getStringArray(Object[] objects,
int maxitems)
Converts an Array of Objects to an Array of Strings using the toString() method. |
|
static boolean |
isSupportedLang(String lang)
This method check the language string base on RFC 1766 to the supported languages in mycore. |
|
static
|
mergeHashSets(HashSet<? extends T> set1,
HashSet<? extends T> set2,
char operation)
merges to HashSets of MyCoreIDs after specific rules |
|
static String |
parseDocumentType(InputStream in)
|
|
static int |
readBlocking(InputStream in,
byte[] b,
int off,
int len)
Reads exactly len bytes from the input stream into the
byte array. |
|
static int |
readBlocking(Reader in,
char[] c,
int off,
int len)
Reads exactly len bytes from the input stream into the
byte array. |
|
static String |
replaceString(String in,
String find,
String newStr)
Returns String in with newStr substituted for find String. |
|
static String |
stringToXML(String in)
This methode replace any characters to XML entity references. |
|
static void |
writeElementToFile(Element elm,
File xml)
The method wrap the org.jdom.Element in a org.jdom.Document and write it to a file. |
|
static void |
writeElementToSysout(Element elm)
The method wrap the org.jdom.Element in a org.jdom.Document and write it to Sysout. |
|
static void |
writeJDOMToFile(Document jdom,
File xml)
The method write a given JDOM Document to a file. |
|
static void |
writeJDOMToSysout(Document jdom)
The method write a given JDOM Document to the system output. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char COMMAND_OR
public static final char COMMAND_AND
public static final char COMMAND_XOR
| Constructor Detail |
|---|
public MCRUtils()
| Method Detail |
|---|
public static final boolean isSupportedLang(String lang)
lang - the language string
public static final String covertDateToISO(String indate)
indate - the date input
public static final GregorianCalendar covertDateToGregorianCalendar(String indate)
indate - the date input
public static final String stringToXML(String in)
in - a string
public static final byte[] getByteArray(Document jdom)
throws MCRPersistenceException
jdom - the JDOM tree
MCRPersistenceExceptionpublic static final String[] getStringArray(Object[] objects)
objects - Array of Objects to be converted
public static final String[] getStringArray(Object[] objects,
int maxitems)
objects - Array of Objects to be convertedmaxitems - The maximum of items to convert
public static boolean copyStream(InputStream source,
OutputStream target)
source - the InputStream to read the bytes fromtarget - out the OutputStream to write the bytes to, may be null
public static boolean copyReader(Reader source,
Writer target)
source - the InputStream to read the bytes fromtarget - out the OutputStream to write the bytes to, may be null
public static final <T> HashSet<T> mergeHashSets(HashSet<? extends T> set1,
HashSet<? extends T> set2,
char operation)
set1 - 1st HashSet to be mergedset2 - 2nd HashSet to be mergedoperation - available COMMAND_XYZ
COMMAND_OR,
COMMAND_AND,
COMMAND_XOR
public static final <T> ArrayList<T> cutArrayList(ArrayList<? extends T> arrayin,
int maxitems)
arrayin - The incoming ArrayListmaxitem - The maximum number of items
public static final int readBlocking(InputStream in,
byte[] b,
int off,
int len)
throws IOException
len bytes from the input stream into the
byte array. This method reads repeatedly from the underlying stream until
all the bytes are read. InputStream.read is often documented to block
like this, but in actuality it does not always do so, and returns early
with just a few bytes. readBlockiyng blocks until all the bytes are read,
the end of the stream is detected, or an exception is thrown. You will
always get as many bytes as you asked for unless you get an eof or other
exception. Unlike readFully, you find out how many bytes you did get.
b - the buffer into which the data is read.off - the start offset of the data.len - the number of bytes to read.
IOException - if an I/O error occurs.
public static final int readBlocking(Reader in,
char[] c,
int off,
int len)
throws IOException
len bytes from the input stream into the
byte array. This method reads repeatedly from the underlying stream until
all the bytes are read. Reader.read is often documented to block like
this, but in actuality it does not always do so, and returns early with
just a few bytes. readBlockiyng blocks until all the bytes are read, the
end of the stream is detected, or an exception is thrown. You will always
get as many bytes as you asked for unless you get an eof or other
exception. Unlike readFully, you find out how many bytes you did get.
c - the buffer into which the data is read.off - the start offset of the data.len - the number of bytes to read.
IOException - if an I/O error occurs.
public static String replaceString(String in,
String find,
String newStr)
Returns String in with newStr substituted for find String.
in - String to editfind - string to matchnewStr - string to substitude for find
public static final void writeElementToFile(Element elm,
File xml)
elm - the JDOM Documentxml - the File instance
public static final void writeJDOMToFile(Document jdom,
File xml)
jdom - the JDOM Documentxml - the File instancepublic static final void writeElementToSysout(Element elm)
elm - the JDOM Documentpublic static final void writeJDOMToSysout(Document jdom)
jdom - the JDOM Documentpublic static ArrayList<String> getAllFileNames(File basedir)
basedir - the File instance of the basic directory
public static ArrayList<String> getAllFileNames(File basedir,
String path)
basedir - the File instance of the basic directorypath - the part of directory path
public static ArrayList<String> getAllDirectoryNames(File basedir)
basedir - the File instance of the basic directory
public static ArrayList<String> getAllDirectoryNames(File basedir,
String path)
basedir - the File instance of the basic directorypath - the part of directory path
public static String arrayToString(Object[] objArray,
String seperator)
public static String parseDocumentType(InputStream in)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||