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


java.lang.Object
   freemarker.ext.xml.NodeListModel

NodeListModel
public class NodeListModel implements TemplateHashModel,TemplateMethodModel,TemplateScalarModel,TemplateSequenceModel,TemplateNodeModel(Code)

A data model adapter for three widespread XML document object model representations: W3C DOM, dom4j, and JDOM. The adapter automatically recognizes the used XML object model and provides a unified interface for it toward the template. The model provides access to all XML InfoSet features of the XML document and includes XPath support if it has access to the XPath- evaluator library Jaxen. The model's philosophy (which closely follows that of XML InfoSet and XPath) is as follows: it always wraps a list of XML nodes (the "nodelist"). The list can be empty, can have a single element, or can have multiple elements. Every operation applied to the model is applied to all nodes in its nodelist. You usually start with a single- element nodelist, usually the root element node or the document node of the XML tree. Additionally, the nodes can contain String objects as a result of certain evaluations (getting the names of elements, values of attributes, etc.)

Implementation note: If you are using W3C DOM documents built by the Crimson XML parser (or you are using the built-in JDK 1.4 XML parser, which is essentially Crimson), make sure you call setNamespaceAware(true) on the javax.xml.parsers.DocumentBuilderFactory instance used for document building even when your documents don't use XML namespaces. Failing to do so, you will experience incorrect behavior when using the documents wrapped with this model.

freemarker.ext.dom.NodeModel
version:
   $Id: NodeListModel.java,v 1.15 2004/01/06 17:06:43 szegedia Exp $
author:
   Attila Szegedi



Constructor Summary
public  NodeListModel(Object nodes)
     Creates a new NodeListModel, wrapping the passed nodes.
Parameters:
  nodes - you can pass it a single XML node from any supporteddocument model, or a Java collection containing any number of nodes.Passing null is prohibited.

Method Summary
public  Objectexec(List arguments)
     Evaluates an XPath expression on XML nodes in this model.
Parameters:
  arguments - the arguments to the method invocation.
public  TemplateModelget(int index)
     Selects a single node from this model's nodelist by its list index and returns a new NodeListModel containing that single node.
public  TemplateModelget(String key)
     Returns a new NodeListModel containing the nodes that result from applying an operator to this model's nodes.
Parameters:
  key - the operator to apply to nodes.
public  StringgetAsString()
     Returns the string representation of the wrapped nodes.
public  TemplateSequenceModelgetChildNodes()
    
public  StringgetNodeName()
    
public  StringgetNodeNamespace()
    
public  StringgetNodeType()
    
public  TemplateNodeModelgetParentNode()
    
public  booleanisEmpty()
     Returns true if this NodeListModel contains no nodes.
public  voidregisterNamespace(String prefix, String uri)
     Registers a namespace prefix-URI pair for subsequent use in NodeListModel.get(String) as well as for use in XPath expressions.
public  intsize()
     Returns the number of nodes in this model's nodelist.


Constructor Detail
NodeListModel
public NodeListModel(Object nodes)(Code)
Creates a new NodeListModel, wrapping the passed nodes.
Parameters:
  nodes - you can pass it a single XML node from any supporteddocument model, or a Java collection containing any number of nodes.Passing null is prohibited. To create an empty model, pass it an emptycollection. If a collection is passed, all passed nodes must belong tothe same XML object model, i.e. you can't mix JDOM and dom4j in a singleinstance of NodeListModel. The model itself doesn't check for this condition,as it can be time consuming, but will throw spuriousClassCastExceptions when it encounters mixed objects.
throws:
  IllegalArgumentException - if you pass null




Method Detail
exec
public Object exec(List arguments) throws TemplateModelException(Code)
Evaluates an XPath expression on XML nodes in this model.
Parameters:
  arguments - the arguments to the method invocation. Expectes exactlyone argument - the XPath expression. a new NodeListModel with nodes selected by applying the XPathexpression to this model's nodelist.
See Also:   freemarker.template.TemplateMethodModel.exec(List)



get
public TemplateModel get(int index)(Code)
Selects a single node from this model's nodelist by its list index and returns a new NodeListModel containing that single node.
Parameters:
  index - the ordinal number of the selected node
See Also:   freemarker.template.TemplateSequenceModel.get(int)



get
public TemplateModel get(String key) throws TemplateModelException(Code)
Returns a new NodeListModel containing the nodes that result from applying an operator to this model's nodes.
Parameters:
  key - the operator to apply to nodes. Available operators are:
Key nameEvaluates to
* or _childrenall direct element children of current nodes (non-recursive).Applicable to element and document nodes.
@* or _attributesall attributes of current nodes. Applicable to elements only.
@attributeNamenamed 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 on dom4j or JDOM models. 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.
_ancestorall ancestors up to root element (recursive) of current nodes.Applicable to same node types as _parent.
_ancestorOrSelfall ancestors of current nodes plus current nodes. Applicable to same node types as _parent.
_cnamethe canonical names of current nodes (namespace URI + local name), one string per node (non-recursive). Applicable to elements and attributes
_contentthe complete content of current nodes, including children elements, text, entity references, and processing instructions (non-recursive). Applicable to elements and documents.
_descendantall recursive descendant element children of current nodes. Applicable to document and element nodes.
_descendantOrSelfall recursive descendant element children of current nodes plus current nodes. Applicable to document and element nodes.
_documentall documents the current nodes belong to. Applicable to all nodes except text.
_doctypedoctypes of the current nodes. Applicable to document nodes only.
_filterTypeis 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 can passas many string arguments as you want, each representing one ofthe types to select: "attribute", "cdata","comment", "document", "documentType", "element", "entity", "entityReference","namespace", "processingInstruction", or"text".
_namethe names of current nodes, one string per node (non-recursive). Applicable to elements and attributes (returns their local names), entity references, processing instructions (returns its target), doctypes (returns its publicID)
_nsprefixthe namespace prefixes of current nodes, one string per node (non-recursive). Applicable to elements and attributes
_nsurithe namespace URIs of current nodes, one string per node (non-recursive). Applicable to elements and attributes
_parentparent elements of current nodes. Applicable to element, attribute, comment, entity, processing instruction.
_qnamethe qualified names of current nodes in [namespacePrefix:]localName form, one string per node (non-recursive). Applicable to elements and attributes
_registerNamespace(prefix, uri)register a XML namespace with the specified prefix and URI forthe current node list and all node lists that are derived from the current node list. After registering, you can use thenodelist["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.
_textthe 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 NOT escaped.
_typeReturns a string describing the type of nodes, onestring per node. The returned values are "attribute","cdata", "comment", "document","documentType", "element", "entity", "entityReference", "namespace", "processingInstruction", "text", or "unknown".
_uniquea copy of the current nodes that keeps only the first occurrence of every node, eliminating duplicates. Duplicates canoccur in the node list by applying uptree-traversals _parent, _ancestor, _ancestorOrSelf,and _document on a node list with multiple elements. I.e. foo._children._parent will return a node list thathas 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.
any other keyelement children of current nodes with name matching the key. This allows for convenience child traversal in book.chapter.title style syntax. Applicable to document and element nodes.
a new NodeListModel containing the nodes that result from applyingthe operator to this model's nodes.
See Also:   freemarker.template.TemplateHashModel.get(String)



getAsString
public String getAsString() throws TemplateModelException(Code)
Returns the string representation of the wrapped nodes. String objects in the nodelist are rendered as-is (with no XML escaping applied). All other nodes are rendered in the default XML serialization format ("plain XML"). This makes the model quite suited for use as an XML-transformation tool. the string representation of the wrapped nodes. String objectsin the nodelist are rendered as-is (with no XML escaping applied). Allother nodes are rendered in the default XML serialization format ("plainXML").
See Also:   freemarker.template.TemplateScalarModel.getAsString



getChildNodes
public TemplateSequenceModel getChildNodes() throws TemplateModelException(Code)



getNodeName
public String getNodeName() throws TemplateModelException(Code)



getNodeNamespace
public String getNodeNamespace() throws TemplateModelException(Code)



getNodeType
public String getNodeType() throws TemplateModelException(Code)



getParentNode
public TemplateNodeModel getParentNode() throws TemplateModelException(Code)



isEmpty
public boolean isEmpty()(Code)
Returns true if this NodeListModel contains no nodes.
See Also:   freemarker.template.TemplateHashModel.isEmpty



registerNamespace
public void registerNamespace(String prefix, String uri)(Code)
Registers a namespace prefix-URI pair for subsequent use in NodeListModel.get(String) as well as for use in XPath expressions.
Parameters:
  prefix - the namespace prefix to use for the namespace
Parameters:
  uri - the namespace URI that identifies the namespace.



size
public int size()(Code)
Returns the number of nodes in this model's nodelist.
See Also:   freemarker.template.TemplateSequenceModel.size



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.