Java Doc for NodeListModel.java in  » Template-Engine » freemarker-2.3.10 » freemarker » ext » jdom » 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 » Template Engine » freemarker 2.3.10 » freemarker.ext.jdom 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   freemarker.ext.jdom.NodeListModel

NodeListModel
public class NodeListModel implements TemplateHashModel,TemplateMethodModel,TemplateCollectionModel,TemplateSequenceModel,TemplateScalarModel(Code)
Provides a template for wrapping JDOM objects. It is capable of storing not only a single JDOM node, but a list of JDOM nodes at once (hence the name). Each node is an instance of any of the core JDOM node classes (except namespaces, which are not supported at the moment), or String for representing text. See individual method documentation for exact details on how the class works. In short:

Note: There is a JDOM independent re-implementation of this class: freemarker.ext.xml.NodeListModel freemarker.ext.xml.NodeListModelfreemarker.ext.dom.NodeModel
author:
   Attila Szegedi
version:
   $Id: NodeListModel.java,v 1.52.2.2 2006/11/14 10:39:58 szegedia Exp $




Constructor Summary
public  NodeListModel(Document document)
     Creates a node list that holds a single Document node.
public  NodeListModel(Element element)
     Creates a node list that holds a single Element node.
public  NodeListModel(List nodes)
     Creates a node list that holds a list of nodes.
Parameters:
  nodes - the list of nodes this template should hold.
public  NodeListModel(List nodes, boolean copy)
     Creates a node list that holds a list of nodes.
Parameters:
  nodes - the list of nodes this template should hold.
Parameters:
  copy - if true, the created template will copy the passed nodes list,so changes to the passed list will not affect the model.

Method Summary
public  Objectexec(List arguments)
     Applies an XPath expression to the node list and returns the resulting node list. In order for this method to work, your application must have access Jaxen library classes.
public  TemplateModelget(String key)
     Provides node list traversal as well as special functions: filtering by name, filtering by node type, shallow-copying, and duplicate removal. While not as powerful as the full XPath support built into the NodeListModel.exec(List) method, it does not require the external Jaxen library to be present at run time.
public  TemplateModelget(int i)
     Retrieves the i-th element of the node list.
public  StringgetAsString()
     This method returns the string resulting from concatenation of string representations of its nodes.
public  booleanisEmpty()
     Returns true if this model contains no nodes.
public  TemplateModelIteratoriterator()
    
public static  voidmain(String[] args)
     Loads a template from a file passed as the first argument, loads an XML document from the standard input, passes it to the template as variable document and writes the result of template processing to standard output.
public  voidregisterNamespace(String prefix, String uri)
     Registers an XML namespace with this node list.
public  intsize()
    


Constructor Detail
NodeListModel
public NodeListModel(Document document)(Code)
Creates a node list that holds a single Document node.



NodeListModel
public NodeListModel(Element element)(Code)
Creates a node list that holds a single Element node.



NodeListModel
public NodeListModel(List nodes)(Code)
Creates a node list that holds a list of nodes.
Parameters:
  nodes - the list of nodes this template should hold. The created templatewill copy the passed nodes list, so changes to the passed list will not affectthe model.



NodeListModel
public NodeListModel(List nodes, boolean copy)(Code)
Creates a node list that holds a list of nodes.
Parameters:
  nodes - the list of nodes this template should hold.
Parameters:
  copy - if true, the created template will copy the passed nodes list,so changes to the passed list will not affect the model. If false, the modelwill reference the passed list and will sense changes in it, although nooperations on the list will be synchronized.




Method Detail
exec
public Object exec(List arguments) throws TemplateModelException(Code)
Applies an XPath expression to the node list and returns the resulting node list. In order for this method to work, your application must have access Jaxen library classes. The implementation does cache the parsed format of XPath expressions in a weak hash map, keyed by the string representation of the XPath expression. As the string object passed as the argument is usually kept in the parsed FreeMarker template, this ensures that each XPath expression is parsed only once during the lifetime of the FreeMarker template that contains it.
Parameters:
  arguments - the list of arguments. Must contain exactly one string that isthe XPath expression you wish to apply. The XPath expression can use any namespaceprefixes that were defined using the NodeListModel.registerNamespace(String,String)method or the nodelist._registerNamespace(prefix, uri) expression in thetemplate. a NodeListModel representing the nodes that are the result of applicationof the XPath to the current node list.



get
public TemplateModel get(String key) throws TemplateModelException(Code)
Provides node list traversal as well as special functions: filtering by name, filtering by node type, shallow-copying, and duplicate removal. While not as powerful as the full XPath support built into the NodeListModel.exec(List) method, it does not require the external Jaxen library to be present at run time. Below are listed the recognized keys. In key descriptions, "applicable to this-and-that node type" means that if a key is applied to a node list that contains a node of non-applicable type a TemplateMethodModel will be thrown. However, you can use _ftype key to explicitly filter out undesired node types prior to applying the restricted-applicability key. Also "current nodes" means nodes contained in this set.
  • * or _children: all direct element children of current nodes (non-recursive). Applicable to element and document nodes.
  • @* or _attributes: all attributes of current nodes. Applicable to elements only.
  • _content the complete content of current nodes (non-recursive). Applicable to elements and documents.
  • _text: the text of current nodes, one string per node (non-recursive). Applicable to elements, attributes, comments, processing instructions (returns its data) and CDATA sections. The reserved XML characters ('<' and '&') are escaped.
  • _plaintext: same as _text, but does not escape any characters, and instead of returning a NodeList returns a SimpleScalar.
  • _name: the names of current nodes, one string per node (non-recursive). Applicable to elements and attributes (returns their local name), entities, processing instructions (returns its target), doctypes (returns its public ID)
  • _qname: the qualified names of current nodes in [namespacePrefix:]localName form, one string per node (non-recursive). Applicable to elements and attributes
  • _cname: the canonical names of current nodes (namespace URI + local name), one string per node (non-recursive). Applicable to elements and attributes
  • _nsprefix: namespace prefixes of current nodes, one string per node (non-recursive). Applicable to elements and attributes
  • _nsuri: namespace URIs of current nodes, one string per node (non-recursive). Applicable to elements and attributes
  • _parent: parent elements of current nodes. Applicable to element, attribute, comment, entity, processing instruction.
  • _ancestor: all ancestors up to root element (recursive) of current nodes. Applicable to same node types as _parent.
  • _ancestorOrSelf: all ancestors of current nodes plus current nodes. Applicable to same node types as _parent.
  • _descendant: all recursive descendant element children of current nodes. Applicable to document and element nodes.
  • _descendantOrSelf: all recursive descendant element children of current nodes plus current nodes. Applicable to document and element nodes.
  • _document: all documents the current nodes belong to. Applicable to all nodes except text.
  • _doctype: doctypes of the current nodes. Applicable to document nodes only.
  • _fname: is a filter-by-name template method model. When called, it will yield a node list that contains only those current nodes whose name matches one of names passed as argument. Attribute names should NOT be prefixed with the at sign (@). Applicable on all node types, however has no effect on unnamed nodes.
  • _ftype: is a filter-by-type template method model. When called, it will yield a node list that contains only those current nodes whose type matches one of types passed as argument. You should pass a single string to this method containing the characters of all types to keep. Valid characters are: e (Element), a (Attribute), n (Entity), d (Document), t (DocType), c (Comment), p (ProcessingInstruction), x (text). If the string anywhere contains the exclamation mark (!), the filter's effect is inverted.
  • _type: Returns a one-character String SimpleScalar containing the typecode of the first node in the node list. Valid characters are: e (Element), a (Attribute), n (Entity), d (Document), t (DocType), c (Comment), p (ProcessingInstruction), x (text). If the type of the node is unknown, returns '?'. If the node list is empty, returns an empty string scalar.
  • _unique: a copy of the current nodes that keeps only the first occurrence of every node, eliminating duplicates. Duplicates can occur in the node list by applying uptree-traversals _parent, _ancestor, _ancestorOrSelf, and _document. I.e. foo._children._parent will return a node list that has duplicates of nodes in foo - each node will have the number of occurrences equal to the number of its children. In these cases, use foo._children._parent._unique to eliminate duplicates. Applicable to all node types.
  • _copy: a copy of the current node list. It is a shallow copy that shares the underlying node list with this node list, however it has a separate namespace registry, so it can be used to guarantee that subsequent changes to the set of registered namespaces does not affect the node lists that were used to create this node list. Applicable to all node types.
  • _registerNamespace(prefix, uri): register a XML namespace with the specified prefix and URI for the current node list and all node lists that are derived from the current node list. After registering, you can use the nodelist["prefix:localname"] or nodelist["@prefix:localname"] syntaxes to reach elements and attributes whose names are namespace-scoped. Note that the namespace prefix need not match the actual prefix used by the XML document itself since namespaces are compared solely by their URI. You can also register namespaces from Java code using the NodeListModel.registerNamespace(String,String) method.
  • @attributeName: named attributes of current nodes. Applicable to elements, doctypes and processing instructions. On doctypes it supports attributes publicId, systemId and elementName. On processing instructions, it supports attributes target and data, as well as any other attribute name specified in data as name="value" pair. The attribute nodes for doctype and processing instruction are synthetic, and as such have no parent. Note, however that @* does NOT operate on doctypes or processing instructions.
  • any other key: element children of current nodes with name matching the key. This allows for convenience child traversal in book.chapter.title style syntax. Note that nodeset.childname is technically equivalent to nodeset._children._fname("childname"), but is both shorter to write and evaluates faster. Applicable to document and element nodes.
The order of nodes in the resulting set is the order of evaluation of the key on each node in this set from left to right. Evaluation of the key on a single node always yields the results in "natural" order (that of the document preorder traversal), even for uptree traversals. As a consequence, if this node list's nodes are listed in natural order, applying any of the keys will produce a node list that is also naturally ordered. As a special case, all node lists that are directly or indirectly generated from a single Document or Element node through repeated invocations of this method will be naturally ordered.
Parameters:
  key - a key that identifies a required set of nodes a new NodeListModel that represents the requested set of nodes.



get
public TemplateModel get(int i) throws TemplateModelException(Code)
Retrieves the i-th element of the node list.



getAsString
public String getAsString() throws TemplateModelException(Code)
This method returns the string resulting from concatenation of string representations of its nodes. Each node is rendered using its XML serialization format, while text (String) is rendered as itself. This greatly simplifies creating XML-transformation templates, as to output a node contained in variable x as XML fragment, you simply write ${x} in the template.



isEmpty
public boolean isEmpty()(Code)
Returns true if this model contains no nodes.



iterator
public TemplateModelIterator iterator()(Code)



main
public static void main(String[] args) throws Exception(Code)
Loads a template from a file passed as the first argument, loads an XML document from the standard input, passes it to the template as variable document and writes the result of template processing to standard output.



registerNamespace
public void registerNamespace(String prefix, String uri)(Code)
Registers an XML namespace with this node list. Once registered, you can refer to the registered namespace using its prefix in the NodeListModel.get(String) method from this node list and all other node lists that are derived from this node list. Use the nodelist["prefix:localname"] or the nodelist["@prefix:localname"] syntax to reach elements and attributes whose names are namespace-scoped. Note that the namespace prefix need not match the actual prefix used by the XML document itself since namespaces are compared solely by their URI. You can also register namespaces during template evaluation using the nodelist._registerNamespace(prefix, uri) syntax in the template. This mechanism is completely independent from the namespace declarations in the XML document itself; its purpose is to give you an easy way to refer to namespace-scoped elements in NodeListModel.get(String) and in XPath expressions passed to NodeListModel.exec(List) . Note also that the namespace prefix registry is shared among all node lists that are created from a single node list - modifying the registry in one affects all others as well. If you want to obtain a namespace "detached" copy of the node list, use the _copy key on it (or call nodeList.get("_copy") directly from your Java code. The returned node list has all the namespaces that the original node list has, but they can be manipulated independently thereon.



size
public int size()(Code)



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.