Java Doc for Gadgets.java in  » Groupware » hipergate » com » knowgate » misc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » hipergate » com.knowgate.misc 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.knowgate.misc.Gadgets

Gadgets
final public class Gadgets (Code)
Miscellaneous functions and utilities.
author:
   Sergio Montoro Ten
version:
   2.1


Field Summary
final public static  char[]HEX_DIGITS
    

Constructor Summary
public  Gadgets()
    

Method Summary
public static  StringASCIIEncode(String sStrIn)
    
public static  StringHTMLDencode(String text)
    
public static  StringHTMLEncode(String text)
    
public static  StringURLEncode(String sStr)
     Return text enconded as an URL.
public static  StringXHTMLEncode(String text)
    
public static  booleancheckEMail(String sEMailAddr)
     Check that an e-mail address is syntactically valid.
public static  Stringchomp(String sSource, char cEndsWith)
     Ensure that a String ends with a given character
Parameters:
  sSource - Input String
Parameters:
  cEndsWith - Character that the String must end with.
public static  Stringchomp(String sSource, String sEndsWith)
     Ensure that a String ends with a given substring
Parameters:
  sSource - Input String
Parameters:
  sEndsWith - Substring that the String must end with.
public static  booleancontains(String sSource, String sRegExp)
    
public static  intcountOccurrences(String sSource, String sSubStr, int iOptions)
    
public static  Stringdechomp(String sSource, String sEndsWith)
     Ensure that a String does not end with a given substring
Parameters:
  sSource - Input String
Parameters:
  sEndsWith - Substring that the String must not end with.
public static  Stringdechomp(String sSource, char cEndsWith)
     Ensure that a String does not end with a given character
Parameters:
  sSource - Input String
Parameters:
  cEndsWith - Character that the String must not end with.
public static  Stringfill(char c, int len)
    
public static  StringformatCurrency(BigDecimal oDec, String sCurrency, String sLanguage, String sCountry)
    
public static  StringformatCurrency(BigDecimal oDec, String sCurrency, String sLanguage)
    
public static  StringformatCurrency(BigDecimal oDec, String sCurrency, Locale oLocale)
    
public static  StringgenerateUUID()
    
public static  StringgetFirstMatchSubStr(String sSource, String sRegExp)
    
public static  intindexOfIgnoreCase(String sSource, String sSought, int iStartAt)
    
public static  intindexOfIgnoreCase(String sSource, String sSought)
    
public  Stringjoin(Collection oList, String sDelimiter)
    
public  Stringjoin(String[] aList, String sDelimiter)
    
public static  Stringleft(String sSource, int nChars)
     Return left portion of a string. This function is similar to substring(sSource, nChars) but it does not raise any exception if sSource.length()>nChars but just return the full sSource input String.
Parameters:
  sSource - Source String
Parameters:
  nChars - Number of characters to the left of String to get.
public static  StringleftPad(String sSource, char cPad, int nChars)
     Add padding characters to the left.
public static  voidmain(String[] argv)
    
public static  booleanmatches(String sSource, String sRegExp)
    
public static  StringremoveChar(String sInput, char cRemove)
    
public static  StringremoveChars(String sInput, String sRemove)
    
public static  Stringreplace(String sSource, String sRegExp, String sNewVal)
    
public static  Stringreplace(String sSource, String sRegExp, String sNewVal, int iOptions)
     Replace a given pattern on a string with a fixed value
Parameters:
  sSource - Source String
Parameters:
  sRegExp - Regular Expression to be matched
Parameters:
  sNewVal - New value for replacement
Parameters:
  iOptions - A set of flags giving the compiler instructions on how totreat the regular expression.
public static  BigDecimalround2(BigDecimal oDec)
    
public static  String[]split(String sInputStr, char cDelimiter)
    
public static  String[]split(String sInputStr, char[] aDelimiter)
    
public static  String[]split(String sInputStr, String sDelimiter)
    
public static  String[]split2(String sInputStr, char cDelimiter)
     Split a String in two parts This method is a special case optimization of split() to be used when the input string is to be splitted by a single character delimiter and there at most one occurrence of that delimiter.
Parameters:
  sInputStr - String to split
Parameters:
  cDelimiter - Single character to be used as delimiter,the String will be splited on the first occurence of character.
public static  String[]split2(String sInputStr, String sDelimiter)
     Split a String in two parts This method is a special case optimization of split() to be used when the input string is to be splitted by a variable length delimiter and there at most one occurrence of that delimiter.
Parameters:
  sInputStr - String to split
Parameters:
  sDelimiter - String to be used as delimiter,the String will be splited on the first occurence of sDelimiter.
public static  CollectionsplitAsCollection(String sInputStr, char cDelimiter)
    

Split a String into a Collection using a character delimiter

Contiguous delimiters with nothing in the middle will delimit empty substrings.
public static  voidtoHexChars(int val, char dst, int dstIndex, int size)
    
public static  StringtoHexString(int val, int size)
    
public static  StringtoHexString(byte[] src, int srcIndex, int size)
    
public static  StringtoHexString(byte[] src)
    
public static  String[]tokenizeCmdLine(String sSource)
    

Take an input string and tokenize each command on it


Parameters:
  sSource - String to be parsed.
Tokens are separated by spaces.


Field Detail
HEX_DIGITS
final public static char[] HEX_DIGITS(Code)




Constructor Detail
Gadgets
public Gadgets()(Code)




Method Detail
ASCIIEncode
public static String ASCIIEncode(String sStrIn)(Code)
Convert an ASCII-8 String to an ASCII-7 String



HTMLDencode
public static String HTMLDencode(String text)(Code)



HTMLEncode
public static String HTMLEncode(String text)(Code)

Return text enconded as HTML.

For example "Tom & Jerry" is encoded as "Tom & Jerry"
Parameters:
  text - Text to encode HTML-encoded text



URLEncode
public static String URLEncode(String sStr)(Code)
Return text enconded as an URL. For example, "Tom's Bookmarks" is encodes as "Tom%27s%20Bookmarks"
Parameters:
  sStr - Text to encode URL-encoded text



XHTMLEncode
public static String XHTMLEncode(String text)(Code)

Return text enconded as XHTML.

ASCII-7 character are returned as they are,any other character is returned as &#code;
Parameters:
  text - String String



checkEMail
public static boolean checkEMail(String sEMailAddr)(Code)
Check that an e-mail address is syntactically valid.
Parameters:
  sEMailAddr - e-mail address to check true if e-mail address is syntactically valid.



chomp
public static String chomp(String sSource, char cEndsWith)(Code)
Ensure that a String ends with a given character
Parameters:
  sSource - Input String
Parameters:
  cEndsWith - Character that the String must end with. If sSource ends with cEndsWith then sSource is returned,else sSource+cEndsWith is returned.



chomp
public static String chomp(String sSource, String sEndsWith)(Code)
Ensure that a String ends with a given substring
Parameters:
  sSource - Input String
Parameters:
  sEndsWith - Substring that the String must end with. If sSource ends with sEndsWith then sSource is returned,else sSource+sEndsWith is returned.



contains
public static boolean contains(String sSource, String sRegExp) throws MalformedPatternException(Code)
Check whether or not a String contains a regular expression
Parameters:
  sSource - String Source
Parameters:
  sRegExp - String Regular Expression boolean false if either sSource or sRegExp are null
throws:
  MalformedPatternException -
since:
   v3.0
See Also:    http://www.savarese.org/oro/docs/OROMatcher/Syntax.html



countOccurrences
public static int countOccurrences(String sSource, String sSubStr, int iOptions) throws MalformedPatternException(Code)
Count occurrences of a given substring
Parameters:
  sSource - String Source
Parameters:
  sSubStr - Substring to be searched (no wildcards)
Parameters:
  iOptions - int org.apache.oro.text.regex.Perl5Compiler.CASE_INSENSITIVE_MASK for case insensitive search int Number of occurrences of sSubStr at sSource.If sSource is null or sSubStr is null then the number of occurrences is zero.If sSource is empty or sSubStr is empty then the number of occurrences is zero.



dechomp
public static String dechomp(String sSource, String sEndsWith)(Code)
Ensure that a String does not end with a given substring
Parameters:
  sSource - Input String
Parameters:
  sEndsWith - Substring that the String must not end with. If sSource does not end with sEndsWith then sSource is returned,else sSource-sEndsWith is returned.



dechomp
public static String dechomp(String sSource, char cEndsWith)(Code)
Ensure that a String does not end with a given character
Parameters:
  sSource - Input String
Parameters:
  cEndsWith - Character that the String must not end with. If sSource does not end with sEndsWith then sSource is returned,else sSource-cEndsWith is returned.



fill
public static String fill(char c, int len) throws IndexOutOfBoundsException(Code)
Fill String with a given character
Parameters:
  c - Character for filling
Parameters:
  len - Number of characters A String with given numbers of characters
throws:
  IndexOutOfBoundsException - if len<0



formatCurrency
public static String formatCurrency(BigDecimal oDec, String sCurrency, String sLanguage, String sCountry)(Code)
Format a BigDecimal as a String following the rules for an specific locale
Parameters:
  oDec - BigDecimal to be formatted
Parameters:
  sCurrency - String ISO 4217 currency code (EUR, USD, GBP, BRL, CNY, etc.)
Parameters:
  sLanguage - String lowercase two-letter ISO-639 code
Parameters:
  sLocale2 - String uppercase two-letter ISO-3166 code String
See Also:    BSI Currency Code Service (ISO 4217 Maintenance Agency)
See Also:    ISO 4217 currency code list
See Also:    ISO 639 language codes
See Also:    ISO 3166 country codes



formatCurrency
public static String formatCurrency(BigDecimal oDec, String sCurrency, String sLanguage)(Code)
Format a BigDecimal as a String following the rules for an specific locale
Parameters:
  oDec - BigDecimal to be formatted
Parameters:
  sCurrency - String ISO 4217 currency code (EUR, USD, GBP, BRL, CNY, etc.)
Parameters:
  sLanguage - String lowercase two-letter ISO-639 code String
See Also:    ISO 4217 currency code list
See Also:    ISO 639 language codes



formatCurrency
public static String formatCurrency(BigDecimal oDec, String sCurrency, Locale oLocale)(Code)
Format a BigDecimal as a String following the rules for an specific locale
Parameters:
  oDec - BigDecimal to be formatted
Parameters:
  sCurrency - String ISO 4217 currency code (EUR, USD, GBP, BRL, CNY, etc.)
Parameters:
  oLocale - Locale used for formatting String
See Also:    java.util.Locale



generateUUID
public static String generateUUID()(Code)
Generate an universal unique identifier An hexadecimal string of 32 characters,created using the machine IP address, current system date, a randon numberand a sequence.



getFirstMatchSubStr
public static String getFirstMatchSubStr(String sSource, String sRegExp) throws MalformedPatternException(Code)
Get the first substring that matches the given regular expression
Parameters:
  sSource - String Source
Parameters:
  sRegExp - String Regular Expression String if no substring matches the regular expression then null is returned
throws:
  MalformedPatternException -
since:
   v3.0
See Also:    http://jakarta.apache.org/oro/api/org/apache/oro/text/regex/Perl5Matcher.html



indexOfIgnoreCase
public static int indexOfIgnoreCase(String sSource, String sSought, int iStartAt)(Code)
Get index of a substring inside another string
Parameters:
  sSource - String String to be scanned
Parameters:
  sSought - Substring to be sought
Parameters:
  iStartAt - int Index to start searching from int Start index of substring or -1 if not found



indexOfIgnoreCase
public static int indexOfIgnoreCase(String sSource, String sSought)(Code)
Get index of a substring inside another string
Parameters:
  sSource - String String to be scanned
Parameters:
  sSought - Substring to be sought int Start index of substring or -1 if not found



join
public String join(Collection oList, String sDelimiter)(Code)
Join a Collection into a String
Parameters:
  oList - Collection to join
Parameters:
  sDelimiter - Delimiter for elements in resulting String List joined as a String



join
public String join(String[] aList, String sDelimiter)(Code)
Join an Array into a String
Parameters:
  aList - Array to join
Parameters:
  sDelimiter - Delimiter for elements in resulting String List joined as a String
since:
   v3.0



left
public static String left(String sSource, int nChars)(Code)
Return left portion of a string. This function is similar to substring(sSource, nChars) but it does not raise any exception if sSource.length()>nChars but just return the full sSource input String.
Parameters:
  sSource - Source String
Parameters:
  nChars - Number of characters to the left of String to get. Left characters of sSource String or null if sSource is null.



leftPad
public static String leftPad(String sSource, char cPad, int nChars)(Code)
Add padding characters to the left.
Parameters:
  sSource - Input String
Parameters:
  cPad - Padding character
Parameters:
  nChars - Final length of the padded string Padded String



main
public static void main(String[] argv)(Code)



matches
public static boolean matches(String sSource, String sRegExp) throws MalformedPatternException(Code)
Check whether or not a String matches a regular expression
Parameters:
  sSource - String Source
Parameters:
  sRegExp - String Regular Expression boolean false if either sSource or sRegExp are null
throws:
  MalformedPatternException -
since:
   v3.0
See Also:    http://www.savarese.org/oro/docs/OROMatcher/Syntax.html



removeChar
public static String removeChar(String sInput, char cRemove)(Code)
Remove a character from a String
Parameters:
  sInput - Input String
Parameters:
  cRemove - Character to be removed The input String without all the occurences of the given character



removeChars
public static String removeChars(String sInput, String sRemove)(Code)
Remove a character set from a String
Parameters:
  sInput - Input String
Parameters:
  sRemove - A String containing all the characters to be removed from input String The input String without all the characters of sRemove



replace
public static String replace(String sSource, String sRegExp, String sNewVal) throws MalformedPatternException(Code)
Replace a given pattern on a string with a fixed value
Parameters:
  sSource - Source String
Parameters:
  sRegExp - Regular Expression to be matched
Parameters:
  sNewVal - New value for replacement
throws:
  MalformedPatternException -
See Also:    http://www.savarese.org/oro/docs/OROMatcher/Syntax.html



replace
public static String replace(String sSource, String sRegExp, String sNewVal, int iOptions) throws MalformedPatternException(Code)
Replace a given pattern on a string with a fixed value
Parameters:
  sSource - Source String
Parameters:
  sRegExp - Regular Expression to be matched
Parameters:
  sNewVal - New value for replacement
Parameters:
  iOptions - A set of flags giving the compiler instructions on how totreat the regular expression. The flags are a logical OR of any number ofthe five org.apache.oro.text.regex.Perl5Compiler MASK constants.

throws:
  MalformedPatternException -
See Also:    http://www.savarese.org/oro/docs/OROMatcher/Syntax.html
CASE_INSENSITIVE_MASKCompiled regular expression should be case insensitive
DEFAULT_MASKUse default mask for compile method
EXTENDED_MASKcompiled regular expression should be treated as a Perl5 extended pattern (i.e., a pattern using the /x modifier)
MULTILINE_MASKCompiled regular expression should treat input as having multiple lines
READ_ONLY_MASKResulting Perl5Pattern should be treated as a read only data structure by Perl5Matcher, making it safe to share a single Perl5Pattern instance among multiple threads without needing synchronization
SINGLELINE_MASKCompiled regular expression should treat input as being a single line



round2
public static BigDecimal round2(BigDecimal oDec)(Code)
Rounds a BigDecimal value to two decimals
Parameters:
  oDec - BigDecimal to be rounded BigDecimal If oDec is null then round2 returns null



split
public static String[] split(String sInputStr, char cDelimiter) throws NullPointerException(Code)

Split a String using a character delimiter

Contiguous delimiters with nothing in the middle will delimit empty substrings.
This is an important behaviour difference between Gadgets.split(String,String) and Gadgets.split(String,char).
Gadgets.split("1;;3;;5;6,";") will return String[4] but Gadgets.split("1;;3;;5;6,';') will return String[6]
Parameters:
  sInputStr - String to split
Parameters:
  cDelimiter - Character Delimiter An array with the splitted substrings
throws:
  NullPointerException - If sInputStr is null



split
public static String[] split(String sInputStr, char[] aDelimiter) throws NullPointerException(Code)

Split a String using any of the given characters as delimiter


Parameters:
  aDelimiter - Character Delimiter Array An array with the splitted substrings
throws:
  NullPointerException - If sInputStr is null or aDelimiter is null



split
public static String[] split(String sInputStr, String sDelimiter) throws NullPointerException(Code)

Split a String using a substring delimiter

Contiguous delimiters with nothing in the middle will be considered has a single delimiter.
This is an important behaviour difference between Gadgets.split(String,String) and Gadgets.split(String,char).
Gadgets.split("1;;3;;5;6,";") will return String[4] but Gadgets.split("1;;3;;5;6,';') will return String[6]
Parameters:
  sInputStr - String to split
Parameters:
  sDelimiter - Substring Delimiter (no regular expressions allowed) An array with the splitted substrings
throws:
  NullPointerException - If sInputStr is null



split2
public static String[] split2(String sInputStr, char cDelimiter) throws NullPointerException(Code)
Split a String in two parts This method is a special case optimization of split() to be used when the input string is to be splitted by a single character delimiter and there at most one occurrence of that delimiter.
Parameters:
  sInputStr - String to split
Parameters:
  cDelimiter - Single character to be used as delimiter,the String will be splited on the first occurence of character. If cDelimiter is not found, or cDelimiter if found as the firstcharacter of sInputStr or cDelimiter if found as the last character ofsInputStr then an array with a single String element is returned. IfcDelimiter is found somewhere in the middle of sInputStr then an arraywith 2 elements is returned.
throws:
  NullPointerException - If sInputStr is null



split2
public static String[] split2(String sInputStr, String sDelimiter) throws NullPointerException(Code)
Split a String in two parts This method is a special case optimization of split() to be used when the input string is to be splitted by a variable length delimiter and there at most one occurrence of that delimiter.
Parameters:
  sInputStr - String to split
Parameters:
  sDelimiter - String to be used as delimiter,the String will be splited on the first occurence of sDelimiter. If sDelimiter is not found, or sInputStr starts with sDelimiter orsInputStr ends with sDelimiter then an array with a single String elementis returned. If sDelimiter is found somewhere in the middle of sInputStrthen an array with 2 elements is returned.
throws:
  NullPointerException - If sInputStr is null



splitAsCollection
public static Collection splitAsCollection(String sInputStr, char cDelimiter) throws NullPointerException(Code)

Split a String into a Collection using a character delimiter

Contiguous delimiters with nothing in the middle will delimit empty substrings.
Parameters:
  sInputStr - String to split
Parameters:
  cDelimiter - Character Delimiter A LinkedList splitted substrings
throws:
  NullPointerException - If sInputStr is null



toHexChars
public static void toHexChars(int val, char dst, int dstIndex, int size)(Code)



toHexString
public static String toHexString(int val, int size)(Code)



toHexString
public static String toHexString(byte[] src, int srcIndex, int size)(Code)
Convert a byte array into its corresponding Hexadecimal String representation
Parameters:
  src - Input array
Parameters:
  srcIndex - Begin Index
Parameters:
  size - Number of bytes to be readed A String with two hexadecimal upper case digits per byte on the input array



toHexString
public static String toHexString(byte[] src)(Code)
Convert a byte array into its corresponding Hexadecimal String representation
Parameters:
  src - Input array A String with two hexadecimal upper case digits per byte on the input array



tokenizeCmdLine
public static String[] tokenizeCmdLine(String sSource) throws StringIndexOutOfBoundsException(Code)

Take an input string and tokenize each command on it


Parameters:
  sSource - String to be parsed.
Tokens are separated by spaces. Single or double quotes are allowed for qualifying string literals. String[] Array of tokens. If sSource is null then the return value is null,if sSource is empty then the return value is an array with a single element being it null.
throws:
  StringIndexOutOfBoundsException -




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.