Java Doc for MapFormat.java in  » IDE-Netbeans » openide » org » openide » util » 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 » IDE Netbeans » openide » org.openide.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.text.Format
      org.openide.util.MapFormat

MapFormat
public class MapFormat extends Format (Code)
A text format similar to MessageFormat but using string rather than numeric keys. You might use use this formatter like this:
MapFormat.format("Hello {name}", map);
Or to have more control over it:
 Map m = new HashMap ();
 m.put ("KEY", "value");
 MapFormat f = new MapFormat (m);
 f.setLeftBrace ("__");
 f.setRightBrace ("__");
 String result = f.format ("the __KEY__ here");
 

author:
   Slavek Psenicka
See Also:   MessageFormat


Field Summary
final static  longserialVersionUID
    

Constructor Summary
public  MapFormat(Map arguments)
     Constructor.

Method Summary
public static  Stringformat(String pattern, Map arguments)
     Designated method.
public  StringBufferformat(Object pat, StringBuffer result, FieldPosition fpos)
     Formats the parsed string by inserting table's values.
public  StringgetLeftBrace()
    
public  MapgetMap()
    
public  StringgetRightBrace()
    
public  booleanisExactMatch()
     Test whether both brackets are required in the expression. If not, use setExactMatch(false) and formatter will ignore missing right bracket.
public  Stringparse(String source)
     Parses the string.
public  ObjectparseObject(String text, ParsePosition status)
     Parses the string.
protected  ObjectprocessKey(String key)
     Returns the value for given key.
public  StringprocessPattern(String newPattern)
     Scans the pattern and prepares internal variables.
public  voidsetExactMatch(boolean flag)
     Specify whether both brackets are required in the expression. If not, use setExactMatch(false) and formatter will ignore missing right bracket.
public  voidsetLeftBrace(String delimiter)
    
public  voidsetMap(Map map)
     Sets argument map This map should contain key-value pairs with key values used in formatted string expression.
public  voidsetRightBrace(String delimiter)
    
public  voidsetThrowExceptionIfKeyWasNotFound(boolean flag)
     Specify whether formatter will throw exception if object for key was not found. If given map does not contain object for key specified, it could throw an exception.
public  booleanwillThrowExceptionIfKeyWasNotFound()
     Test whether formatter will throw exception if object for key was not found. If given map does not contain object for key specified, it could throw an exception.

Field Detail
serialVersionUID
final static long serialVersionUID(Code)
Array with to-be-skipped blocks




Constructor Detail
MapFormat
public MapFormat(Map arguments)(Code)
Constructor. For common work use format(pattern, arguments) .
Parameters:
  arguments - keys and values to use in the format




Method Detail
format
public static String format(String pattern, Map arguments)(Code)
Designated method. It gets the string, initializes HashFormat object and returns converted string. It scans pattern for {} brackets, then parses enclosed string and replaces it with argument's get() value.
Parameters:
  pattern - String to be parsed.
Parameters:
  arguments - Map with key-value pairs to replace. Formatted string



format
public StringBuffer format(Object pat, StringBuffer result, FieldPosition fpos)(Code)
Formats the parsed string by inserting table's values.
Parameters:
  pat - a string pattern
Parameters:
  result - Buffer to be used for result.
Parameters:
  fpos - position Formatted string



getLeftBrace
public String getLeftBrace()(Code)
Returns string used as left brace



getMap
public Map getMap()(Code)
Returns argument map



getRightBrace
public String getRightBrace()(Code)
Returns string used as right brace



isExactMatch
public boolean isExactMatch()(Code)
Test whether both brackets are required in the expression. If not, use setExactMatch(false) and formatter will ignore missing right bracket. Advanced feature.



parse
public String parse(String source)(Code)
Parses the string. Does not yet handle recursion (where the substituted strings contain {n} references.) New format.



parseObject
public Object parseObject(String text, ParsePosition status)(Code)
Parses the string. Does not yet handle recursion (where the substituted strings contain %n references.)



processKey
protected Object processKey(String key)(Code)
Returns the value for given key. Subclass may define its own beahvior of this method. For example, if key is not defined, subclass can return string.
Parameters:
  key - Key. Value for this key.



processPattern
public String processPattern(String newPattern) throws IllegalArgumentException(Code)
Scans the pattern and prepares internal variables.
Parameters:
  newPattern - String to be parsed.
exception:
  IllegalArgumentException - if number of arguments exceeds BUFSIZE orparser found unmatched brackets (this exception should be switched offusing setExactMatch(false)).



setExactMatch
public void setExactMatch(boolean flag)(Code)
Specify whether both brackets are required in the expression. If not, use setExactMatch(false) and formatter will ignore missing right bracket. Advanced feature.
Parameters:
  flag - If true, formatter will ignore missing right bracket (default = false)



setLeftBrace
public void setLeftBrace(String delimiter)(Code)
Sets string used as left brace
Parameters:
  delimiter - Left brace.



setMap
public void setMap(Map map)(Code)
Sets argument map This map should contain key-value pairs with key values used in formatted string expression. If value for key was not found, formatter leave key unchanged (except if you've set setThrowExceptionIfKeyWasNotFound(true), then it fires IllegalArgumentException.
Parameters:
  map - the argument map



setRightBrace
public void setRightBrace(String delimiter)(Code)
Sets string used as right brace
Parameters:
  delimiter - Right brace.



setThrowExceptionIfKeyWasNotFound
public void setThrowExceptionIfKeyWasNotFound(boolean flag)(Code)
Specify whether formatter will throw exception if object for key was not found. If given map does not contain object for key specified, it could throw an exception. If does not throw, key is left unchanged.
Parameters:
  flag - If true, formatter throws IllegalArgumentException.



willThrowExceptionIfKeyWasNotFound
public boolean willThrowExceptionIfKeyWasNotFound()(Code)
Test whether formatter will throw exception if object for key was not found. If given map does not contain object for key specified, it could throw an exception. Returns true if throws. If not, key is left unchanged.



Methods inherited from java.text.Format
public Object clone()(Code)(Java Doc)
final public String format(Object obj)(Code)(Java Doc)
abstract public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)(Code)(Java Doc)
public AttributedCharacterIterator formatToCharacterIterator(Object obj)(Code)(Java Doc)
abstract public Object parseObject(String source, ParsePosition pos)(Code)(Java Doc)
public Object parseObject(String source) throws ParseException(Code)(Java Doc)

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.