Java Doc for StringMap.java in  » Web-Server » Brazil » sunlabs » brazil » 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 » Web Server » Brazil » sunlabs.brazil.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.util.Dictionary
      sunlabs.brazil.util.StringMap

All known Subclasses:   sunlabs.brazil.util.http.MimeHeaders,
StringMap
public class StringMap extends Dictionary (Code)
The StringMap class is a substitute for the Hashtable. The StringMap has the following properties:
  • Maps case-insensitive string keys to string values.
  • The case of the keys is preserved.
  • Values may be null.
  • Preserves the relative order of the data.
  • The same key may appear multiple times in a single map.
  • This map is implemented via a Vector, and as such, as the number of keys increases, the time required to search will go up.

author:
   Colin Stevens (colin.stevens@sun.com)
version:
   1.11, 00/03/29


Field Summary
 Vectorkeys
    
 Vectorvalues
    

Constructor Summary
public  StringMap()
     Creates an empty StringMap.

Method Summary
public  voidadd(String key, String value)
     Maps the given case-insensitive key to the specified value in this StringMap.

The new mapping is added to this StringMap even if the given key already has a mapping.

public  voidclear()
     Removes all the keys and values from this StringMap.
public  Enumerationelements()
     Returns an enumeration of the values in this StringMap.
public  Stringget(int index)
     Returns the value at the specified index.
public  Stringget(String key)
     Returns the value that the specified case-insensitive key maps to in this StringMap.

The same key may appear multiple times in the enumeration; this method always returns the value associated with the first occurrence of the specified key.

public  Objectget(Object key)
     Performs the same job as get(String).
public  StringgetKey(int index)
     Returns the key at the specified index.
public  booleanisEmpty()
     Tests if there are any elements in this StringMap.
public  Enumerationkeys()
     Returns an enumeration of the keys in this StringMap.
public  voidput(int index, String value)
     Maps the key at the given index to the specified value in this StringMap.
public  voidput(String key, String value)
     Maps the given case-insensitive key to the specified value in this StringMap.

The value can be retrieved by calling get with a key that is case-insensitive equal to the given key.

If this StringMap already contained a mapping for the given key, the old value is forgotten and the new specified value is used. The case of the prior key is retained in that case.

public  Objectput(Object key, Object value)
     Performs the same job as put(String, String).
public  voidremove(String key)
     Removes the given case-insensitive key and its corresponding value from this StringMap.
public  voidremove(int i)
    
public  Objectremove(Object key)
     Performs the same job as remove(String).
public  intsize()
     Returns the number of elements in this StringMap.
public  StringtoString()
     Returns a string representation of this StringMap in the form of a set of entries, enclosed in braces and separated by the characters ", ".

Field Detail
keys
Vector keys(Code)



values
Vector values(Code)




Constructor Detail
StringMap
public StringMap()(Code)
Creates an empty StringMap.




Method Detail
add
public void add(String key, String value)(Code)
Maps the given case-insensitive key to the specified value in this StringMap.

The new mapping is added to this StringMap even if the given key already has a mapping. In this way it is possible to create a key that maps to two or more values.

Since the same key may appear multiple times in this StringMap, it is necessary to iterate over the entire StringMap to retrieve all values associated with a given key.
Parameters:
  key - The new key. May not be null.
Parameters:
  value - The new value. May be null.
See Also:   StringMap.put(String,String)
See Also:   StringMap.keys




clear
public void clear()(Code)
Removes all the keys and values from this StringMap.



elements
public Enumeration elements()(Code)
Returns an enumeration of the values in this StringMap. The elements of the enumeration are strings. An enumeration of the values.
See Also:   StringMap.keys



get
public String get(int index) throws IndexOutOfBoundsException(Code)
Returns the value at the specified index. The index ranges from 0 to size() - 1.

This method can be used to iterate over all the values in this StringMap in the order in which they were inserted, subject to any intervening deletions.
Parameters:
  index - The index of the key. The value at the specified index.
throws:
  IndexOutOfBoundsException - if the index is out of the allowed range.




get
public String get(String key)(Code)
Returns the value that the specified case-insensitive key maps to in this StringMap.

The same key may appear multiple times in the enumeration; this method always returns the value associated with the first occurrence of the specified key. In order to get all the values, it is necessary to iterate over the entire StringMap to retrieve all the values associated with a given key.
Parameters:
  key - A key in this StringMap. May not be null. The value to which the specified key is mapped, ornull if the key is not in the StringMap.
See Also:   StringMap.keys




get
public Object get(Object key)(Code)
Performs the same job as get(String). It exists so this class can extend the Dictionary class.
Parameters:
  key - Must be a String. A String value.
throws:
  ClassCastException - if the key is not a String.
See Also:   StringMap.get(String)



getKey
public String getKey(int index) throws IndexOutOfBoundsException(Code)
Returns the key at the specified index. The index ranges from 0 to size() - 1.

This method can be used to iterate over all the keys in this StringMap in the order in which they were inserted, subject to any intervening deletions.
Parameters:
  index - The index of the key. The key at the specified index.
throws:
  IndexOutOfBoundsException - if the index is out of the allowed range.




isEmpty
public boolean isEmpty()(Code)
Tests if there are any elements in this StringMap. Returns true if there are no elements,false otherwise.



keys
public Enumeration keys()(Code)
Returns an enumeration of the keys in this StringMap. The elements of the enumeration are strings.

The same key may appear multiple times in the enumeration, not necessarily consecutively. Since get always returns the value associated with the first occurrence of a given key, a StringMap cannot be enumerated in the same fashion as a Hashtable. Instead, the caller should use:

 Enumeration keys = map.keys();
 Enumeration values = map.elements();
 while (keys.hasMoreElements()) {
 String key = (String) keys.nextElement();
 String value = (String) values.nextElement();
 }
 
or:
 for (int i = 0; i < map.size(); i++) {
 String key = map.getKey(i);
 String value = map.get(i);
 }
 
An enumeration of the keys.
See Also:   StringMap.elements
See Also:   StringMap.size
See Also:   StringMap.getKey
See Also:   StringMap.get



put
public void put(int index, String value)(Code)
Maps the key at the given index to the specified value in this StringMap. The index ranges from 0 to size() - 1.
Parameters:
  index - The index of the key. The value at the specified index.
throws:
  IndexOutOfBoundsException - if the index is out of the allowed range.



put
public void put(String key, String value)(Code)
Maps the given case-insensitive key to the specified value in this StringMap.

The value can be retrieved by calling get with a key that is case-insensitive equal to the given key.

If this StringMap already contained a mapping for the given key, the old value is forgotten and the new specified value is used. The case of the prior key is retained in that case. Otherwise the case of the new key is used.
Parameters:
  key - The new key. May not be null.
Parameters:
  value - The new value. May be null. The previous value to which key was mapped,or null if the the key did not map to anyvalue.




put
public Object put(Object key, Object value)(Code)
Performs the same job as put(String, String). It exists so this class can extend the Dictionary class.
Parameters:
  key - Must be a String.
Parameters:
  value - Must be a String. The previous value to which key was mapped,or null if the the key did not map to anyvalue.
throws:
  ClassCastException - if the key or value is not aString.
See Also:   StringMap.put(String,String)



remove
public void remove(String key)(Code)
Removes the given case-insensitive key and its corresponding value from this StringMap. This method does nothing if the key is not in this StringMap.

The same key may appear in multiple times in this StringMap; this method only removes the first occurrence of the key.
Parameters:
  key - The key that needs to be removed. Must not benull.




remove
public void remove(int i)(Code)



remove
public Object remove(Object key)(Code)
Performs the same job as remove(String). It exists so this class can extend the Dictionary class.
Parameters:
  key - Must be a String. The string value to which the key had been mapped, ornull if the key did not have a mapping.
throws:
  ClassCastException - if the key is not a String.



size
public int size()(Code)
Returns the number of elements in this StringMap. Every occurrence of keys that appear multiple times is counted. The number of elements in this StringMap.
See Also:   StringMap.keys



toString
public String toString()(Code)
Returns a string representation of this StringMap in the form of a set of entries, enclosed in braces and separated by the characters ", ". Each entry is rendered as the key, an equals sign "=", and the associated value. The string representation of this StringMap.



Methods inherited from java.util.Dictionary
abstract public Enumeration<V> elements()(Code)(Java Doc)
abstract public V get(Object key)(Code)(Java Doc)
abstract public boolean isEmpty()(Code)(Java Doc)
abstract public Enumeration<K> keys()(Code)(Java Doc)
abstract public V put(K key, V value)(Code)(Java Doc)
abstract public V remove(Object key)(Code)(Java Doc)
abstract public int size()(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.