Package com.nomagic.utils
Class CameoUtilities
java.lang.Object
com.nomagic.utils.CameoUtilities
- Direct Known Subclasses:
Utilities
General purpose utilities.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringclearAllLine(String src, String trash) Removes all trash from stringstatic voidcopy(InputStream input, OutputStream output) static voidCopies all bytes from Reader into Writer.static RectangleCreates rectangle from vector of points.deepPointsClone(List<Point> v) Makes a deep clone of vector that contains points.deepPointsClone(List<Point> v, boolean cloneList) Makes a deep clone of vector that contains points.static booleanhasExtension(String name, String extension) Checks if given file name has given file extension.static booleanhasExtension(String name, List<String> extensions) Checks if given file name has one of given file extensions.static booleanReturns true of both objects are nulls or equalstatic booleanReturns true of both objects are nulls or equalstatic voidnormalizes rectangle mRectToDraw;static voidNormalizes rectangle; Calculates rectangle size and location using firstCorner and secondCorner.static voidremoveClosestToTheMiddle(List objects, Object o1, Object o2) Removes an object from the list which is closest to the middle.static StringremoveExtension(String name, Collection<String> extensions) Removes file extension form given file name.static StringremoveFromLine(String line, String trash) Removes from line trash linestatic StringReplaces string fragment with another stringstatic StringreplaceNewLine(String string, String lineSeparator) Separate lines with the provided separator string.static byte[]toByteArray(InputStream stream) Copies the given file into the array of bytes.static byte[]toByteArray(String bytes) Returns byte array from string formatted in toString(byte[]) method.static StringtoString(byte[] data) Returns string representation of the given byte array.static StringtoString(InputStream inputStream, String encoding) Get String representation of inputStream
-
Constructor Details
-
CameoUtilities
public CameoUtilities()
-
-
Method Details
-
clearAllLine
Removes all trash from string- Parameters:
src- String from witch thrash should be removedtrash- Trash string.- Returns:
- cleared string or same if nothing was cleared
-
isEqual
Returns true of both objects are nulls or equal- Parameters:
obj1- First object.obj2- Second object.- Returns:
- boolean
-
isEqual
Returns true of both objects are nulls or equal- Parameters:
obj1- object list.obj2- object list.- Returns:
- boolean
-
toString
public static String toString(InputStream inputStream, @CheckForNull String encoding) throws IOException Get String representation of inputStream- Parameters:
inputStream- The given inputStream- Returns:
- String representation
- Throws:
IOException
-
replaceNewLine
Separate lines with the provided separator string.- Parameters:
string- input string.lineSeparator- line separator.- Returns:
- result string.
-
copy
Copies all bytes from Reader into Writer. Closes the reader and writer.- Parameters:
input- the reader.output- the writer.- Throws:
IOException
-
copy
- Throws:
IOException
-
toByteArray
Copies the given file into the array of bytes.- Parameters:
stream- the given file.- Returns:
- the byte array with the context of the file;null if some errors occurs
-
toByteArray
Returns byte array from string formatted in toString(byte[]) method.- Parameters:
bytes- the given string.- Returns:
- the byte array.
-
toString
Returns string representation of the given byte array.- Parameters:
data- the given bytes array.- Returns:
- the string representation (every byte is represented as hex string separated by space)
-
removeFromLine
Removes from line trash line- Parameters:
line- the given line.trash- characters as string.- Returns:
- The given string without From Line.
-
hasExtension
Checks if given file name has one of given file extensions. -
hasExtension
Checks if given file name has given file extension. -
removeExtension
Removes file extension form given file name. -
deepPointsClone
Makes a deep clone of vector that contains points.- Parameters:
v- List of point.- Returns:
- vector
-
deepPointsClone
Makes a deep clone of vector that contains points.- Parameters:
v- List of point.cloneList- True if clone to new list.- Returns:
- vector
-
normalize
Normalizes rectangle; Calculates rectangle size and location using firstCorner and secondCorner.- Parameters:
rectangle- rectangle to normalizefirstCorner- first cornersecondCorner- second corner
-
normalize
normalizes rectangle mRectToDraw;- Parameters:
rect- rectangle to normalize
-
createRectFromList
Creates rectangle from vector of points.- Parameters:
v- List of point- Returns:
- null if vector was empty
-
replace
Replaces string fragment with another string- Parameters:
src- Source string.pattern- String pattern.replaceWith- The another string.- Returns:
- string.
-
removeClosestToTheMiddle
Removes an object from the list which is closest to the middle.- Parameters:
objects- - a list of objects.o1- - first object.o2- - second object.
-