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


java.lang.Object
   simple.util.Resolver

Resolver
public class Resolver implements Serializable(Code)
This is used to match String's with the first pattern that String matches. A pattern consists of characters with either the '*' or '?' characters as wild characters. The '*' character is completely wild meaning that is will match nothing or a long sequence of characters. The '?' character matches a single character.

If the '?' character immediately follows the '*' character then the match is made as any sequence of characters up to the first match of the next character. For example "/*?/index.jsp" will match all files preceeded by only a single path. So "/pub/index.jsp" will match, however "/pub/bin/index.jsp" will not, as it has two paths. So, in effect the '*?' sequence will match anything or nothing up to the first occurence of the next character in the pattern.

A design goal of the Resolver was to make it capable of high performance in a multithreaded environment. In order to achieve a high performance the Resolver can cache the resolutions it makes so that if the same text is given to the Resolver.resolve method a cached result can be retrived quickly which will decrease the length of time a thread occupies the synchronized method. The cache used is a CacheList.

The semantics of the resolver are such that the last pattern inserted with a wild string is the first one checked for a match. This means that if a sequence of insertions like insert(a,b) insert(x,y) is made and then a resolve(z) is attemped then z will be compared to x first and then a, if z matches x then y is given as the result and if z matches a then b will be returned, remember if z matches both a and x then y will be the result due to the fact that is was the last pattern inserted.
author:
   Niall Gallagher
See Also:   simple.util.cache.CacheList




Constructor Summary
public  Resolver()
     The default constructor will create a Resolver without a large cache size.
public  Resolver(int size)
     This constructor allows resolves to be cached for increased performance.

Method Summary
public synchronized  voidclear()
     This is used to clear all matches from the resolver.
public synchronized  booleancontains(String pattern)
     This will check this Resolver to see if the pattern given is used by this Resolver, if it is this will return true.
public synchronized  booleancontains(Match match)
     This will check this Resolver to see if the match given is used by this Resolver, if it is this will return true.
public synchronized  MatchgetMatch(int pos)
     This will return the corrosponding Match at the specified position.
public synchronized  MatchgetMatch(String pattern)
     This will return the corrosponding Match at the specified position.
public synchronized  Match[]getMatches()
     Retrives an array of Match's of each pair that was entered into this Resolver.
public synchronized  intindexOf(String pattern)
     Used to find the position of the Match stored using the specified pattern.
public synchronized  intindexOf(String pattern, int from)
     Used to find the position of the Match stored using the specified pattern.
public synchronized  voidinsert(String pattern, String match)
     This will add a new pattern with its resolution.
public synchronized  voidinsert(String pattern, String match, int pos)
     This will add a new pattern with its resolution.
public synchronized  booleanisEmpty()
     This can be used to determine wheather or not there is any entrys in the Resolver.
public synchronized  voidremove(int pos)
     This will remove the entry in this Resolver so that the pattern will not be used to resolve String's any more.
public synchronized  voidremove(String pattern)
     This will remove the entry in this Resolver so that the pattern will not be used to resolve String's any more.
public synchronized  voidremove(Match match)
     This will remove the entry in this Resolver so that the pattern will not be used to resolve String's any more.
public synchronized  Stringresolve(String text)
     This will search the patterns in this Resolver to see if there is a pattern in it that matches the string given. This will search the patterns from the last entered pattern to the first entered.
public synchronized  intsize()
     This will return the number of entrys that have been inserted into this Resolver.


Constructor Detail
Resolver
public Resolver()(Code)
The default constructor will create a Resolver without a large cache size. This is intended for use when the requests for resolve tend to use strings that are reasonably similar. If the strings issued to this instance are dramatically different then the cache tends to be an overhead rather than a bonus.



Resolver
public Resolver(int size)(Code)
This constructor allows resolves to be cached for increased performance. When strings tend to be reused for pattern matching then this constructor should be used. The cache is a simple Least Recently Used List. So only patterns that have a high 'hit' rate will remain in the cache.

If a caching is done then an CacheList is used. This is a transient object so that when this instance of the Resolver is serialized list is cleared.
Parameters:
  size - if this is true the caching of resolves is doneusing a CacheList





Method Detail
clear
public synchronized void clear()(Code)
This is used to clear all matches from the resolver. This ensures that the resolver contains no matches and that the resolution cache is cleared. This is used to that the resolver can be reused and have new pattern matches inserted into it for resolution.



contains
public synchronized boolean contains(String pattern)(Code)
This will check this Resolver to see if the pattern given is used by this Resolver, if it is this will return true.
Parameters:
  pattern - the pattern that is used resolvingString's this will return true if this patternexists in this Resolver



contains
public synchronized boolean contains(Match match)(Code)
This will check this Resolver to see if the match given is used by this Resolver, if it is this will return true.
Parameters:
  match - this is a specific match and pattern pair this will return true if this matchexists in this Resolver



getMatch
public synchronized Match getMatch(int pos)(Code)
This will return the corrosponding Match at the specified position. This can be used in conjunction with the indexOf method to remove matches.
Parameters:
  pos - the position Match to retrive this will retrun the match object at that position



getMatch
public synchronized Match getMatch(String pattern)(Code)
This will return the corrosponding Match at the specified position. This can be used in conjunction with the indexOf method to remove matches. This is a convienence method that avoids having to use the indexOf method.
Parameters:
  pattern - the position Match to retrive returns the match object at that position



getMatches
public synchronized Match[] getMatches()(Code)
Retrives an array of Match's of each pair that was entered into this Resolver. The elements in the array are ordered to represent the order they were made. the array of Match objects that exist



indexOf
public synchronized int indexOf(String pattern)(Code)
Used to find the position of the Match stored using the specified pattern. This operates in a similar way to the Vector.indexOf method.
Parameters:
  pattern - the pattern that the Matchis stored using this will return the position of that pattern



indexOf
public synchronized int indexOf(String pattern, int from)(Code)
Used to find the position of the Match stored using the specified pattern. This operates in a similar way to the Vector.indexOf method.
Parameters:
  pattern - the pattern that the Matchis stored using
Parameters:
  from - this starts checking from this position this will return the position of that pattern



insert
public synchronized void insert(String pattern, String match)(Code)
This will add a new pattern with its resolution. This will be added to the end of the list and will be the first pattern checked for a match when the resolve method is invoked. This inserts the pair at the end of the list and so it will be the first pattern checked. If the match is an empty string then there is not insertion made.
Parameters:
  pattern - this is the pattern that will resolve this
Parameters:
  match - the String returned when a correctmatch is made
throws:
  NullPointerException - if either string is null



insert
public synchronized void insert(String pattern, String match, int pos)(Code)
This will add a new pattern with its resolution. This will be added to the end of the list and will be the first pattern checked for a match when the resolve method is invoked. This will insert the pair into the position specified. This behaves like the Vector.insertElementAt method, by bumping all entrys up one position. If the match is an empty string then there is not insertion made.
Parameters:
  pattern - this is the pattern that will resolve this
Parameters:
  match - the String returned when a correctmatch is made
Parameters:
  pos - this is the position to insert the pair into
throws:
  NullPointerException - if either string is null



isEmpty
public synchronized boolean isEmpty()(Code)
This can be used to determine wheather or not there is any entrys in the Resolver. If this Resolver is empty this will return true, there must be at least one entry in the Resolver. this returns true is there are no elements



remove
public synchronized void remove(int pos)(Code)
This will remove the entry in this Resolver so that the pattern will not be used to resolve String's any more. This behaves like the Vector.removeElementAt.
Parameters:
  pos - this is the position that is removed from this



remove
public synchronized void remove(String pattern)(Code)
This will remove the entry in this Resolver so that the pattern will not be used to resolve String's any more. If the wild string is parameter is null then there is a NullPointerException. This behaves like the Vector.removeElementAt method.
Parameters:
  pattern - this is the pattern that is removed from this



remove
public synchronized void remove(Match match)(Code)
This will remove the entry in this Resolver so that the pattern will not be used to resolve String's any more. If the wild string is parameter is null then there is a NullPointerException. This will only use the Match.getPattern to remove the match. This is a convienence method that it can be used with getMatches.
Parameters:
  match - this is the match that is removed from this



resolve
public synchronized String resolve(String text)(Code)
This will search the patterns in this Resolver to see if there is a pattern in it that matches the string given. This will search the patterns from the last entered pattern to the first entered. So that the last entered patterns are the most searched patterns and will resolve it first if it matches.

Although it is criticial that this perform well this method is synchronized. The reasnon for this is that if there was several threads modifing the Resolver at the same time ConcurrentModificationException exceptions would be thrown this would reduce the usefulness of this object.
Parameters:
  text - this is the String to be resolved will return the String that patternresolves to




size
public synchronized int size()(Code)
This will return the number of entrys that have been inserted into this Resolver. This uses the Vector's size implementation to determine the number of entrys. this returns the number of pattern/match pairs



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.