|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.electric.database.text.TextUtils
public class TextUtils
This class is a collection of text utilities.
Nested Class Summary | |
---|---|
static class |
TextUtils.CellsByDate
Comparator class for sorting Cells by their date. |
static class |
TextUtils.CellsByName
Comparator class for sorting Cells by their name (NOT considering numbers in the names). |
static class |
TextUtils.CellsByVersion
Comparator class for sorting Cells by their version number. |
static class |
TextUtils.CellsByView
Comparator class for sorting Cells by their view order. |
static class |
TextUtils.NetworksByName
Comparator class for sorting Networks by their name. |
static class |
TextUtils.ObjectsByToString
Comparator class for sorting Objects by their string name. |
static class |
TextUtils.PrefsByName
Comparator class for sorting Preferences by their name. |
static class |
TextUtils.UnitScale
Unit is a typesafe enum class that describes a unit scale (metric factors of 10). |
static class |
TextUtils.WhatToSearch
Class to define the kind of text string to search |
Field Summary | |
---|---|
static java.util.Comparator<Connection> |
CONNECTIONS_ORDER
|
static java.util.Comparator<java.lang.String> |
STRING_NUMBER_ORDER
A comparator object for sorting Strings that may have numbers in them. |
Constructor Summary | |
---|---|
TextUtils()
|
Method Summary | |
---|---|
static double |
atof(java.lang.String text)
Method to parse the floating-point number in a string. |
static double |
atof(java.lang.String text,
java.lang.Double defaultVal)
Method to parse the floating-point number in a string, using a default value if no number can be determined. |
static double |
atof(java.lang.String text,
java.lang.Double defaultVal,
AbstractTextDescriptor.Unit unitType,
Technology tech)
Method to parse the floating-point number in a string, using a default value if no number can be determined, and presuming a type of unit. |
static double |
atofDistance(java.lang.String text)
Method to parse the floating-point number in a string, assuming that it is a distance value in the current technology. |
static double |
atofDistance(java.lang.String text,
Technology tech)
Method to parse the floating-point number in a string, assuming that it is a distance value in the current technology. |
static int |
atoi(java.lang.String s)
Method to parse the number in a string. |
static int |
atoi(java.lang.String s,
int pos)
Method to parse the number in a string. |
static int |
atoi(java.lang.String s,
int pos,
int base)
Method to parse the number in a string. |
static char |
canonicChar(char ch)
Returns canonic char for ignore-case comparison . |
static java.lang.String |
canonicString(java.lang.String s)
Returns canonic string for ignore-case comparision . |
static double |
convertDistance(double value,
Technology tech,
TextUtils.UnitScale unitScale)
Method to convert a database coordinate into real spacing. |
static double |
convertFromDistance(double value,
Technology tech,
TextUtils.UnitScale unitScale)
Method to convert real spacing into a database coordinate. |
static java.lang.String |
convertToEngineeringNotation(double value)
Method to converts a floating point number into engineering units such as pico, micro, milli, etc. |
static java.lang.String |
convertToEngineeringNotation(double value,
java.lang.String unit)
Method to converts a floating point number into engineering units such as pico, micro, milli, etc. |
static java.lang.String |
convertToEngineeringNotation(double time,
java.lang.String unit,
int precpower)
|
static java.lang.String |
correctName(java.lang.String n,
boolean onlyBrackets,
boolean correctBrackets)
Method to replace all special characters in the instance name coming from external files such as"/".. |
static int |
findStringInString(java.lang.String string,
java.lang.String search,
int startingPos,
boolean caseSensitive,
boolean reverse)
Method to find a string inside of another string. |
static java.lang.String |
formatDate(java.util.Date date)
Method to convert a Date to a String using local TimeZone. |
static java.lang.String |
formatDateGMT(java.util.Date date)
Method to convert a Date to a String using GMT TimeZone. |
static java.lang.String |
formatDistance(double v)
Method to convert a distance to a string, using scale from the current technology if necessary. |
static java.lang.String |
formatDistance(double v,
Technology tech)
Method to convert a distance to a string, using scale from the current technology if necessary. |
static java.lang.String |
formatDouble(double v)
Method to convert a double to a string. |
static java.lang.String |
formatDouble(double v,
int numFractions)
Method to convert a double to a string. |
static java.lang.String |
formatDoublePostFix(double v)
Method to convert a double to a string. |
static java.util.List<java.lang.String> |
getAllResources(java.lang.String resourceName)
Method to examine a path and return all resources found there. |
static java.lang.String |
getElapsedTime(long milliseconds)
Method to describe a time value as a String. |
static java.lang.String |
getExtension(java.net.URL url)
Method to return the extension of the file in a URL. |
static java.io.File |
getFile(java.net.URL url)
Get the file for the URL. |
static java.lang.String |
getFileNameWithoutExtension(java.lang.String fileName)
Method to return the pure file name of a file path. |
static java.lang.String |
getFileNameWithoutExtension(java.net.URL url)
Method to return the pure file name of a URL. |
static java.lang.String |
getFilePath(java.net.URL url)
Method to return the directory path part of a URL (excluding the file name). |
static java.lang.String |
getTextOnClipboard()
Method for obtaining the string on the system clipboard. |
static java.awt.Color[] |
getTransparentColors(java.lang.String str)
Method to convert a string with color values into an array of colors. |
static java.io.InputStream |
getURLStream(java.net.URL url)
Method to open an input stream to a URL. |
static java.io.InputStream |
getURLStream(java.net.URL url,
java.lang.StringBuffer errorMsg)
Method to open an input stream to a URL. |
static double |
getValueOfExpression(java.lang.String expression)
Method to get the numeric value of a string that may be an expression. |
static boolean |
isANumber(java.lang.String pp)
Method to determine whether or not a string is a number. |
static boolean |
isANumberPostFix(java.lang.String pp)
Method to determine whether or not a string is a postfix formatted number, such as 1.02f. |
static boolean |
isDigit(char ch)
Determines if the specified character is a ISO-LATIN-1 digit ( '0' through '9' ). |
static boolean |
isLetterOrDigit(char ch)
Determines if the specified character is a letter or digit. |
static java.lang.String |
makeUnits(double value,
AbstractTextDescriptor.Unit units)
Method to convert a floating point value to a string, given that it is a particular type of unit. |
static java.net.URL |
makeURLToFile(java.lang.String fileName)
Method to convert a file path to a URL. |
static java.lang.Number |
parsePostFixNumber(java.lang.String s,
TextUtils.UnitScale us)
Try to parse the user input String s into a Number. |
static java.lang.String[] |
parseString(java.lang.String line,
java.lang.String delim)
Method to break a line into keywords, separated by white space or comma |
static void |
printLongString(java.lang.String str)
Method to print a very long string. |
static void |
setTextOnClipboard(java.lang.String text)
Method to set the string stored on the system clipboard. |
static boolean |
startsWithIgnoreCase(java.lang.String main,
java.lang.String with)
Method to determine if one string is a subset of another, but case-insensitive. |
static java.lang.String |
toBlankPaddedString(int value,
int width)
Method to convert an integer to a string that is left-padded with spaces |
static boolean |
URLExists(java.net.URL url)
Method to tell whether a given URL exists. |
static boolean |
URLExists(java.net.URL url,
java.lang.StringBuffer errorMsg)
Method to tell whether a given URL exists. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.util.Comparator<java.lang.String> STRING_NUMBER_ORDER
public static final java.util.Comparator<Connection> CONNECTIONS_ORDER
Constructor Detail |
---|
public TextUtils()
Method Detail |
---|
public static boolean isDigit(char ch)
'0'
through '9'
).
This can be method instead of Character, if we are not ready to handle Arabi-Indic, Devanagaru and other digits.
ch
- the character to be tested.
true
if the character is a ISO-LATIN-1 digit;
false
otherwise.Character.isDigit(char)
public static boolean isLetterOrDigit(char ch)
A character is considered to be a letter or digit if either
Character.isLetter(char ch)
or
TextUtils.isDigit(char ch)
returns
true
for the character.
ch
- the character to be tested.
true
if the character is a letter or digit;
false
otherwise.isDigit(char)
,
Character.isJavaLetterOrDigit(char)
,
Character.isLetter(char)
public static char canonicChar(char ch)
ch
- given char.
public static java.lang.String canonicString(java.lang.String s)
s
- given String
public static boolean startsWithIgnoreCase(java.lang.String main, java.lang.String with)
main
- the main string.with
- the substring.
public static double atof(java.lang.String text)
text
- the string with a number in it.
public static double atof(java.lang.String text, java.lang.Double defaultVal)
text
- the string to convert to a double.defaultVal
- the value to return if the string cannot be converted to a double.
If 'defaultVal' is null and the text cannot be converted to a number, the method returns 0.
public static double atofDistance(java.lang.String text, Technology tech)
text
- the string to convert to a double.tech
- the technology to use for the conversion.
If it is not a layout technology, then use pure numbers.
public static double atofDistance(java.lang.String text)
text
- the string to convert to a double.
public static double atof(java.lang.String text, java.lang.Double defaultVal, AbstractTextDescriptor.Unit unitType, Technology tech)
text
- the string to convert to a double.defaultVal
- the value to return if the string cannot be converted to a double.
If 'defaultVal' is null and the text cannot be converted to a number, the method returns 0.unitType
- the type of unit being examined (handles postfix characters).
public static int atoi(java.lang.String s)
There are many reasons to use this method instead of Integer.parseInt...
s
- the string with a number in it.
public static int atoi(java.lang.String s, int pos)
s
- the string with a number in it.pos
- the starting position in the string to find the number.
public static int atoi(java.lang.String s, int pos, int base)
s
- the string with a number in it.pos
- the starting position in the string to find the number.base
- the forced base of the number (0 to determine it automatically).
public static double getValueOfExpression(java.lang.String expression)
expression
- the string that may be an expression.
public static java.awt.Color[] getTransparentColors(java.lang.String str)
str
- the string, with colors separated by "/" and the RGB values in
a color separated by ",". For example, "255,0,0/0,0,255" describes two
colors: red and blue.
public static java.lang.String formatDoublePostFix(double v)
v
- the double value to format.
public static java.lang.String formatDouble(double v)
v
- the double value to format.
public static java.lang.String formatDistance(double v, Technology tech)
v
- the distance value to format.
public static java.lang.String formatDistance(double v)
v
- the distance value to format.
public static java.lang.String formatDouble(double v, int numFractions)
v
- the double value to format.numFractions
- the number of digits to the right of the decimal point.
public static java.lang.String formatDate(java.util.Date date)
date
- the date to format.
public static java.lang.String formatDateGMT(java.util.Date date)
date
- the date to format.
public static java.lang.String convertToEngineeringNotation(double value)
value
- floating point value to be converted to engineering notation.public static java.lang.String convertToEngineeringNotation(double value, java.lang.String unit)
value
- floating point value to be converted to engineering notation.unit
- a unit string to append to the result (null for none).public static java.lang.String convertToEngineeringNotation(double time, java.lang.String unit, int precpower)
public static java.lang.String toBlankPaddedString(int value, int width)
value
- the integer value.width
- the minimum field width.
If the result is less than this, extra spaces are added to the beginning.
public static boolean isANumber(java.lang.String pp)
pp
- the string to test.
public static boolean isANumberPostFix(java.lang.String pp)
pp
- the string to test.
public static java.lang.String getElapsedTime(long milliseconds)
milliseconds
- the time span in milli-seconds.
public static int findStringInString(java.lang.String string, java.lang.String search, int startingPos, boolean caseSensitive, boolean reverse)
string
- the main string being searched.search
- the string being located in the main string.startingPos
- the starting position in the main string to look (0 to search the whole string).caseSensitive
- true to do a case-sensitive search.reverse
- true to search from the back of the string.
public static java.lang.String[] parseString(java.lang.String line, java.lang.String delim)
line
- the string to tokenize.delim
- the delimiters.
public static double convertDistance(double value, Technology tech, TextUtils.UnitScale unitScale)
value
- the database coordinate to convert.tech
- the technology to use for conversion (provides a real scaling).unitScale
- the type of unit desired.
public static double convertFromDistance(double value, Technology tech, TextUtils.UnitScale unitScale)
value
- the real distance to convert.tech
- the technology to use for conversion (provides a real scaling).unitScale
- the type of unit desired.
public static java.lang.String makeUnits(double value, AbstractTextDescriptor.Unit units)
value
- the floating point value.units
- the type of unit.
public static java.lang.Number parsePostFixNumber(java.lang.String s, TextUtils.UnitScale us) throws java.lang.NumberFormatException
Formats: Integer, Long, Double
s
- the string to parse.us
- the UnitScale to presume if none are given (null for no scaling).
java.lang.NumberFormatException
- if the String is not a parsable Number.public static void printLongString(java.lang.String str)
public static void setTextOnClipboard(java.lang.String text)
text
- the new text for the clipboard. If text is null, the contents is clean.public static java.lang.String getTextOnClipboard()
public static java.net.URL makeURLToFile(java.lang.String fileName)
fileName
- the path to the file.
public static java.io.File getFile(java.net.URL url)
new File(url.getPath())
returns an illegal leading slash on windows,
and has forward slashes instead of back slashes.
This method generates the correct File using
new File(url.toURI())
use getPath()
on the returned File
to get the correct String file path.
This should only be needed when running an external process under windows with command line arguments containing file paths. Otherwise, the Java IO code does the correct conversion.
url
- the URL to convert to a File.
public static java.lang.String getFilePath(java.net.URL url)
url
- the URL to the file.
public static java.lang.String getFileNameWithoutExtension(java.net.URL url)
url
- the URL to the file.
public static java.lang.String getFileNameWithoutExtension(java.lang.String fileName)
fileName
- full name of file.
public static java.lang.String getExtension(java.net.URL url)
url
- the URL to the file.
public static java.io.InputStream getURLStream(java.net.URL url)
url
- the URL to the file.
public static java.io.InputStream getURLStream(java.net.URL url, java.lang.StringBuffer errorMsg)
url
- the URL to the file.errorMsg
- a string buffer in which to print any error message. If null,
any error message is printed to System.out
public static boolean URLExists(java.net.URL url)
url
- the URL in question.
public static boolean URLExists(java.net.URL url, java.lang.StringBuffer errorMsg)
url
- the URL in question.errorMsg
- a string buffer in which to print any error message.
If null, errors are not printed.
public static java.util.List<java.lang.String> getAllResources(java.lang.String resourceName)
resourceName
- the path to examine.
public static java.lang.String correctName(java.lang.String n, boolean onlyBrackets, boolean correctBrackets)
n
- onlyBrackets
- correctBrackets
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |