Class Format
java.lang.Object
ecmwf.common.text.Format
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe Class DuplicatedChooseScore. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringFind the best score to select the line.static StringThe options are in the following format: (.= /readme.txt) standby=yes (== {avhrr_n.*}) standby=never;delay=2h And this method looks for the first line which apply to the selected key.static StringcleanTextContent(String text) Clean text content.static StringCompress.static StringDecode.static StringescapeHTML(String s) Escape html.extractSearchParameters(String defaultOptionName, String input) Extract search parameters.static StringformatBoolean(boolean bool) Format boolean.static StringFormat current time.static StringformatDuration(long duration) Format duration.static StringformatDuration(long start, long stop) Format duration.static StringformatLong(long n, int width) Format long.static StringformatLong(long n, int width, boolean zero) Format long.static StringformatPercentage(long size, long sent) Format percentage.static StringformatPercentageOf(long size, long sent) Format percentage with the of, over and left to comment.static StringformatRate(long size, long duration) Format the transfer rate in GBytes/s or MBytes/s or KBytes/s or Bytes/s depending of the size.static StringformatSize(long bytes) Format size.static StringformatString(Object text, int width) Format string.static StringformatString(Object text, int width, boolean onRight) Format string.static StringformatString(String text, int width) Format string.static StringformatString(String text, int width, char empty) Format string.static StringformatString(String text, int width, char empty, boolean onRight) Format string.static StringformatTime(long date) Format time.static StringformatTime(String format, long date) Format time.static StringformatTime(Timestamp date) Format time.static StringformatUntil(long lastDate) Format until.static StringformatValue(long value, int width) Format value.static StringfromXMLValue(String target) From xml value.static StringgetClassName(Object object) Gets the class name.static StringgetCleanPath(String path) Clean the path by removing all occurrences of "///" by "/", all "\" by "/" and all trailing "/".static longgetDuration(String duration) Gets the duration with default value in hours.static StringGets the ftp list.static StringgetHash(byte[] bytes) Return a hash of the string.static StringgetHostAddress(String host) Gets the host address.static StringgetHostName(String host) Gets the host name.static StringgetLastMessage(Throwable t, String defaultMessage) Gets the message.static doublegetMBitsPerSeconds(long size, long duration) Get the transfer rate in Mbits/s.static StringGets the message.static StringgetMessage(Throwable t, String defaultMessage, int limit) Gets the message.static String[]getParameters(String message, String token) Gets the parameters.static StringHide.static booleanisValidEmail(String email) Check if this is a valid email.static booleanCheck if this is a valid identifier (with letters, digits and allowed characters).static boolean_matches.static booleanmatchesGlobPattern(String pattern, String input) Matches glob pattern.static StringnormalizePath(String path) Normalize path.static StringobjectToString(Object object) Object to string.static longparseDurationWithDefaultInMillis(String duration) Parse the duration with default value in milliseconds.static voidreplaceAll(StringBuilder target, String name, Object value) Replace all.static StringreplaceAll(String target, String name, Object value) Replace all.static voidreplaceAllExt(StringBuilder target, String name, String value) Replace all.static StringreplaceAllExt(String target, String name, String value) Replace all.static byte[]Converts into bytes.static byte[]Converts into bytes.static StringtoHexa(byte[] bytes) Converts into hexa.static <E> StringConverts into list.static <E> StringConverts into list.static doubletoMBits(long bytes) Convert Bytes in Mbits.static ObjecttoObject(byte[] bytes) Converts into object.static longConverts into time.static longConverts into long.static StringtoWMOFormat(String name) Converts into wmo format.static StringtoXMLValue(String target) Converts into xml value.static StringtrimString(String text, int maxSize) Trim string.static StringtrimString(String message, String empty) Trim string.static Stringuncompress(byte[] bytes) Uncompress.static Stringuncompress(String str) Uncompress.static Stringunix2sqlWildcards(String unix) Convert unix 2 sql wildcards and also escape the special sql characters '%' and '_'.static StringunixToWindows(String text) Unix to windows.static byte[]windowsToUnix(byte[] data, int offset, int len) Windows to unix.static StringwindowsToUnix(String text) Windows to unix.
-
Method Details
-
unix2sqlWildcards
-
isValidEmail
Check if this is a valid email.- Parameters:
email- the email- Returns:
- valid
-
isValidId
-
escapeHTML
-
formatSize
Format size.- Parameters:
bytes- the bytes- Returns:
- the string
-
toMBits
public static double toMBits(long bytes) Convert Bytes in Mbits.- Parameters:
bytes- the bytes- Returns:
- the string
-
formatTime
-
formatTime
Format time.- Parameters:
date- the date- Returns:
- the string
-
formatCurrentTime
-
formatTime
-
formatDuration
Format duration.- Parameters:
start- the startstop- the stop- Returns:
- the string
-
toList
-
toList
-
formatDuration
Format duration.- Parameters:
duration- the duration- Returns:
- the string
-
formatBoolean
Format boolean.- Parameters:
bool- the bool- Returns:
- the string
-
formatLong
Format long.- Parameters:
n- the nwidth- the width- Returns:
- the string
-
formatLong
Format long.- Parameters:
n- the nwidth- the widthzero- the zero- Returns:
- the string
-
formatRate
Format the transfer rate in GBytes/s or MBytes/s or KBytes/s or Bytes/s depending of the size.- Parameters:
size- the sizeduration- the duration- Returns:
- the string
-
getMBitsPerSeconds
public static double getMBitsPerSeconds(long size, long duration) Get the transfer rate in Mbits/s.- Parameters:
size- the sizeduration- the duration- Returns:
- the string
-
formatPercentage
Format percentage.- Parameters:
size- the sizesent- the sent- Returns:
- the string
-
formatPercentageOf
Format percentage with the of, over and left to comment.- Parameters:
size- the sizesent- the sent- Returns:
- the string
-
formatString
-
formatString
-
formatString
-
formatString
-
formatString
-
parseDurationWithDefaultInMillis
Parse the duration with default value in milliseconds.- Parameters:
duration- the duration string- Returns:
- the duration
- Throws:
NumberFormatException- the number format exception
-
getDuration
Gets the duration with default value in hours.- Parameters:
duration- the duration- Returns:
- the duration
- Throws:
NumberFormatException- the number format exception
-
formatValue
Format value.- Parameters:
value- the valuewidth- the width- Returns:
- the string
-
trimString
-
formatUntil
Format until.- Parameters:
lastDate- the last date- Returns:
- the string
-
fromXMLValue
-
hide
-
windowsToUnix
-
windowsToUnix
public static byte[] windowsToUnix(byte[] data, int offset, int len) Windows to unix.- Parameters:
data- the dataoffset- the offsetlen- the len- Returns:
- the byte[]
-
unixToWindows
-
replaceAll
Replace all.- Parameters:
target- the targetname- the namevalue- the value
-
replaceAllExt
public static void replaceAllExt(StringBuilder target, String name, String value) throws IOException Replace all. Also check if there are no parameters configured after the parameter name (.e.g $target[2..3]) in target.- Parameters:
target- the targetname- the namevalue- the value- Throws:
IOException- Signals that an I/O exception has occurred.
-
replaceAllExt
Replace all. Also check if there are no parameters configured after the parameter name (.e.g $target[2..3]) in target.- Parameters:
target- the targetname- the namevalue- the value- Returns:
- the string
- Throws:
IOException- Signals that an I/O exception has occurred.
-
replaceAll
-
toTime
Converts into time.- Parameters:
time- the time- Returns:
- the long
-
toTime
-
toXMLValue
-
trimString
-
toHexa
Converts into hexa.- Parameters:
bytes- the bytes- Returns:
- the string
-
getHash
Return a hash of the string.- Parameters:
bytes- the bytes- Returns:
- the string
-
toBytes
Converts into bytes.- Parameters:
hexa- the hexa- Returns:
- the byte[]
- Throws:
NumberFormatException- the number format exception
-
toBytes
Converts into bytes.- Parameters:
object- the object- Returns:
- the byte[]
- Throws:
IOException- Signals that an I/O exception has occurred.
-
toObject
Converts into object.- Parameters:
bytes- the bytes- Returns:
- the object
- Throws:
IOException- Signals that an I/O exception has occurred.ClassNotFoundException- the class not found exception
-
getHostAddress
-
getHostName
-
getParameters
-
getLastMessage
-
getMessage
-
getMessage
-
decode
Decode.- Parameters:
s- the s- Returns:
- the string
- Throws:
UnsupportedEncodingException- the unsupported encoding exception
-
getClassName
-
choose
Find the best score to select the line. If no match is found return the first line. /data1/ecmwf/atmos/ ($dataTransfer[target].=DA) /data1/ecmwf/atmos/DA/ ($dataTransfer[target].=DW) /data1/ecmwf/atmos/DW/ ($dataTransfer[target].=EA) /data1/ecmwf/atmos/EA/ ($dataTransfer[target].=EW) /data1/ecmwf/atmos/EW/ ($dataTransfer[target].=S1) /data1/ecmwf/atmos/S1/ ($dataTransfer[target].=M1) /data1/ecmwf/atmos/M1/ ($dataTransfer[target].=T1) /data1/ecmwf/atmos/T1/- Parameters:
options- the options to choose from.- Returns:
- the selection
- Throws:
Format.DuplicatedChooseScore- the duplicated choose scoreScriptException- the script exception
-
choose
The options are in the following format: (.= /readme.txt) standby=yes (== {avhrr_n.*}) standby=never;delay=2h And this method looks for the first line which apply to the selected key. For example, if the key is /etc/readme.txt then the first line will be selected and the method will return "standby=yes". The operator for comparison are the following: ".=" starts with; "==" equals to, if the second part is between {} then it is considered as a regular expression (regex); "=." ends with; "!=" different than.- Parameters:
key- the key to look for.options- the options to choose from.- Returns:
- the selection or null if nothing is found
- Throws:
IOException- Signals that an I/O exception has occurred.
-
objectToString
-
toWMOFormat
-
getCleanPath
-
normalizePath
Normalize path.- Parameters:
path- the path- Returns:
- the string
- Throws:
FileNotFoundException- the file not found exception
-
compress
Compress.- Parameters:
str- the str- Returns:
- the string
- Throws:
IOException- Signals that an I/O exception has occurred.
-
uncompress
Uncompress.- Parameters:
str- the str- Returns:
- the string
- Throws:
IOException- Signals that an I/O exception has occurred.
-
uncompress
Uncompress.- Parameters:
bytes- the bytes- Returns:
- the string
- Throws:
IOException- Signals that an I/O exception has occurred.
-
cleanTextContent
-
getFtpList
-
matches
-
extractSearchParameters
Extract search parameters. This method is extracting the parameters in the following form: "param1=value1 param2=space\\ char param3=equal\\=char" (the ' ' and = characters can be escaped)- Parameters:
defaultOptionName- the default option nameinput- the input- Returns:
- the map
-
matchesGlobPattern
Matches glob pattern. This method uses the PathMatcher interface with the glob syntax to perform matching based on Unix-style wildcard patterns ('*' and '?').- Parameters:
pattern- the patterninput- the input- Returns:
- true, if successful
-