Java Doc for PropertyBasedDocumentFactory.java in  » Search-Engine » mg4j » it » unimi » dsi » mg4j » document » 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 » Search Engine » mg4j » it.unimi.dsi.mg4j.document 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   it.unimi.dsi.mg4j.document.AbstractDocumentFactory
      it.unimi.dsi.mg4j.document.PropertyBasedDocumentFactory

All known Subclasses:   it.unimi.dsi.mg4j.document.IdentityDocumentFactory,  it.unimi.dsi.mg4j.document.DispatchingDocumentFactory,  it.unimi.dsi.mg4j.document.PdfDocumentFactory,  it.unimi.dsi.mg4j.document.HtmlDocumentFactory,  test.it.unimi.dsi.mg4j.document.FirstByteDocumentFactory,  test.it.unimi.dsi.mg4j.document.NullDocumentFactory,
PropertyBasedDocumentFactory
abstract public class PropertyBasedDocumentFactory extends AbstractDocumentFactory (Code)
A document factory initialised by default properties.

Many document factories need a number of default values that are used when the metadata passed to it.unimi.dsi.mg4j.document.DocumentFactory.getDocument(java.io.InputStreamReference2ObjectMap) is not sufficient or lacks some key. This abstract class provides a common base for all such factories.

All concrete implementations of this class should have:

  1. an empty constructor;
  2. a constructor taking a it.unimi.dsi.fastutil.objects.Reference2ObjectMap having java.lang.Enum keys;
  3. a constructor taking a Properties object;
  4. a constructor taking a string array.

In the third case, the properties will be parsed by the PropertyBasedDocumentFactory.parseProperties(Properties) method. In the fourth case, by the PropertyBasedDocumentFactory.parseProperties(String[]) method.

Since all implementations are expected to provide such constructors, corresponding have been provided to simplify factory instantiation.

If the implementation needs to read and parse some key, it must override the PropertyBasedDocumentFactory.parseProperty(String,String[],Reference2ObjectMap) method.

Keys are specified with a dotted notation. The last dot-separated token is the actual key. The prefix is used to select properties: only properties with a prefix that is a prefix of the current class name are considered. Moreover, if a property with a completely specified prefix (i.e., a prefix that is a class name) is not parsed an exception will be thrown.

This class provide helpers methods PropertyBasedDocumentFactory.resolve(Enum,Reference2ObjectMap) and PropertyBasedDocumentFactory.resolveNotNull(Enum,Reference2ObjectMap) to help in writing implementations of it.unimi.dsi.mg4j.document.DocumentFactory.getDocument(java.io.InputStreamReference2ObjectMap) that handle default metadata correctly.


Inner Class :public static enum MetadataKeys

Field Summary
protected  Reference2ObjectMap<Enum<?>, Object>defaultMetadata
     The set of default metadata for this factory.

Constructor Summary
protected  PropertyBasedDocumentFactory(Reference2ObjectMap<Enum<?>, Object> defaultMetadata)
    
protected  PropertyBasedDocumentFactory(Properties properties)
    
protected  PropertyBasedDocumentFactory(String[] property)
    
protected  PropertyBasedDocumentFactory()
    

Method Summary
protected static  StringensureJustOne(String key, String[] values)
     This method checks that the array of values contains just one element, and returns the element.
Parameters:
  key - the property name (used to build the exception message).
Parameters:
  values - the array of values.
public static  PropertyBasedDocumentFactorygetInstance(Class klass, String[] property)
    
public static  PropertyBasedDocumentFactorygetInstance(Class klass, Properties properties)
    
public static  PropertyBasedDocumentFactorygetInstance(Class klass)
    
public static  PropertyBasedDocumentFactorygetInstance(Class klass, Reference2ObjectMap<Enum<?>, Object> metadata)
    
public  Reference2ObjectMap<Enum<?>, Object>parseProperties(Properties properties)
     Scans the property set, parsing the properties that concern this class.
Parameters:
  properties - a set of properties.
public  Reference2ObjectMap<Enum<?>, Object>parseProperties(String[] property)
     Parses the given list of properties either as key=value specs (value may be a list of comma-separated values), or as filenames.
Parameters:
  property - an array of strings specifying properties.
protected  booleanparseProperty(String key, String[] valuesUnused, Reference2ObjectMap<Enum<?>, Object> metadataUnused)
     Parses a property with given key and value, adding it to the given map.
protected  Objectresolve(Enum key, Reference2ObjectMap<Enum<?>, Object> metadata)
     Resolves the given key against the given metadata, falling back to the default metadata.
Parameters:
  key - a key.
Parameters:
  metadata - a metadata map.
protected  Objectresolve(Enum key, Reference2ObjectMap<Enum<?>, Object> metadata, Object o)
     Resolves the given key against the given metadata, falling back to the provided object.
Parameters:
  key - a key.
Parameters:
  metadata - a metadata map.
Parameters:
  o - a default object.
protected  ObjectresolveNotNull(Enum key, Reference2ObjectMap<Enum<?>, Object> metadata)
     Resolves the given key against the given metadata, falling back to the default metadata and guaranteeing a non-null result.
Parameters:
  key - a key.
Parameters:
  metadata - a metadata map.
public static  booleansameKey(Enum enumKey, String key)
     A utility method checking whether the downcased name of an Enum is equal to a given string.

This class uses an Enum ( MetadataKeys ) to store valid property keys.


Field Detail
defaultMetadata
protected Reference2ObjectMap<Enum<?>, Object> defaultMetadata(Code)
The set of default metadata for this factory. It is initalised by PropertyBasedDocumentFactory.parseProperties(Properties) .

This field must be massaged after serialisation, as its keys must be String.intern interned .





Constructor Detail
PropertyBasedDocumentFactory
protected PropertyBasedDocumentFactory(Reference2ObjectMap<Enum<?>, Object> defaultMetadata)(Code)



PropertyBasedDocumentFactory
protected PropertyBasedDocumentFactory(Properties properties) throws ConfigurationException(Code)



PropertyBasedDocumentFactory
protected PropertyBasedDocumentFactory(String[] property) throws ConfigurationException(Code)



PropertyBasedDocumentFactory
protected PropertyBasedDocumentFactory()(Code)




Method Detail
ensureJustOne
protected static String ensureJustOne(String key, String[] values) throws ConfigurationException(Code)
This method checks that the array of values contains just one element, and returns the element.
Parameters:
  key - the property name (used to build the exception message).
Parameters:
  values - the array of values. the only value (if the array contains exactly one element).
throws:
  ConfigurationException - iff values does not contain a single element.



getInstance
public static PropertyBasedDocumentFactory getInstance(Class klass, String[] property) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException(Code)



getInstance
public static PropertyBasedDocumentFactory getInstance(Class klass, Properties properties) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException(Code)



getInstance
public static PropertyBasedDocumentFactory getInstance(Class klass) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException(Code)



getInstance
public static PropertyBasedDocumentFactory getInstance(Class klass, Reference2ObjectMap<Enum<?>, Object> metadata) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException(Code)



parseProperties
public Reference2ObjectMap<Enum<?>, Object> parseProperties(Properties properties) throws ConfigurationException(Code)
Scans the property set, parsing the properties that concern this class.
Parameters:
  properties - a set of properties. a metadata map.



parseProperties
public Reference2ObjectMap<Enum<?>, Object> parseProperties(String[] property) throws ConfigurationException(Code)
Parses the given list of properties either as key=value specs (value may be a list of comma-separated values), or as filenames.
Parameters:
  property - an array of strings specifying properties. a metadata map.



parseProperty
protected boolean parseProperty(String key, String[] valuesUnused, Reference2ObjectMap<Enum<?>, Object> metadataUnused) throws ConfigurationException(Code)
Parses a property with given key and value, adding it to the given map.

Currently this implementation just parses the MetadataKeys.LOCALE property.

Subclasses should do their own parsing, returing true in case of success and returning super.parseProperty() otherwise.
Parameters:
  key - the property key.
Parameters:
  valuesUnused - the property value; this is an array, because properties may have a list of comma-separated values.
Parameters:
  metadataUnused - the metadata map. true if the property was parsed correctly, false if it was ignored.




resolve
protected Object resolve(Enum key, Reference2ObjectMap<Enum<?>, Object> metadata)(Code)
Resolves the given key against the given metadata, falling back to the default metadata.
Parameters:
  key - a key.
Parameters:
  metadata - a metadata map. the value returned by metadata for key, or the valuereturned by PropertyBasedDocumentFactory.defaultMetadata for key if the former is null (the latter,of course, might be null).



resolve
protected Object resolve(Enum key, Reference2ObjectMap<Enum<?>, Object> metadata, Object o)(Code)
Resolves the given key against the given metadata, falling back to the provided object.
Parameters:
  key - a key.
Parameters:
  metadata - a metadata map.
Parameters:
  o - a default object. the value returned by metadata for key, or o if theformer is null.



resolveNotNull
protected Object resolveNotNull(Enum key, Reference2ObjectMap<Enum<?>, Object> metadata)(Code)
Resolves the given key against the given metadata, falling back to the default metadata and guaranteeing a non-null result.
Parameters:
  key - a key.
Parameters:
  metadata - a metadata map. the value returned by metadata for key, or the valuereturned by PropertyBasedDocumentFactory.defaultMetadata for key if the former is null; if thelatter is null, too, a NoSuchElementException will be thrown.



sameKey
public static boolean sameKey(Enum enumKey, String key)(Code)
A utility method checking whether the downcased name of an Enum is equal to a given string.

This class uses an Enum ( MetadataKeys ) to store valid property keys. We follow both the uppercase naming convention for enums and the lowercase naming convention for properties, and this method encapsulates the method calls that necessary to correctly handle key parsing.
Parameters:
  enumKey - a key expressed as an Enum.
Parameters:
  key - a key expressed as a string. true if key is equal to the downcased of enumKey.




Methods inherited from it.unimi.dsi.mg4j.document.AbstractDocumentFactory
protected void ensureFieldIndex(int index)(Code)(Java Doc)
public String toString()(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.