1
22
23 package com.liferay.portal.xml;
24
25 import com.liferay.portal.kernel.util.TranslatedList;
26 import com.liferay.portal.kernel.xml.Attribute;
27 import com.liferay.portal.kernel.xml.Branch;
28 import com.liferay.portal.kernel.xml.CDATA;
29 import com.liferay.portal.kernel.xml.Comment;
30 import com.liferay.portal.kernel.xml.Document;
31 import com.liferay.portal.kernel.xml.Element;
32 import com.liferay.portal.kernel.xml.Entity;
33 import com.liferay.portal.kernel.xml.Namespace;
34 import com.liferay.portal.kernel.xml.Node;
35 import com.liferay.portal.kernel.xml.ProcessingInstruction;
36 import com.liferay.portal.kernel.xml.QName;
37 import com.liferay.portal.kernel.xml.Text;
38 import com.liferay.portal.kernel.xml.XPath;
39
40 import java.util.List;
41
42
47 public class NodeList<E, F> extends TranslatedList<E, F> {
48
49 public NodeList(List<E> newList, List<F> oldList) {
50 super(newList, oldList);
51 }
52
53 protected TranslatedList<E, F> newInstance(
54 List<E> newList, List<F> oldList) {
55
56 return new NodeList<E, F>(newList, oldList);
57 }
58
59 protected F toOldObject(E o) {
60 if (o instanceof Attribute) {
61 AttributeImpl attributeImpl = (AttributeImpl)o;
62
63 return (F)attributeImpl.getWrappedAttribute();
64 }
65 else if (o instanceof CDATA) {
66 CDATAImpl cdataImpl = (CDATAImpl)o;
67
68 return (F)cdataImpl.getWrappedCDATA();
69 }
70 else if (o instanceof Comment) {
71 CommentImpl commentImpl = (CommentImpl)o;
72
73 return (F)commentImpl.getWrappedComment();
74 }
75 else if (o instanceof Document) {
76 DocumentImpl documentImpl = (DocumentImpl)o;
77
78 return (F)documentImpl.getWrappedDocument();
79 }
80 else if (o instanceof Element) {
81 ElementImpl elementImpl = (ElementImpl)o;
82
83 return (F)elementImpl.getWrappedElement();
84 }
85 else if (o instanceof Entity) {
86 EntityImpl entityImpl = (EntityImpl)o;
87
88 return (F)entityImpl.getWrappedEntity();
89 }
90 else if (o instanceof Namespace) {
91 NamespaceImpl namespaceImpl = (NamespaceImpl)o;
92
93 return (F)namespaceImpl.getWrappedNamespace();
94 }
95 else if (o instanceof ProcessingInstruction) {
96 ProcessingInstructionImpl processingInstructionImpl =
97 (ProcessingInstructionImpl)o;
98
99 return
100 (F)processingInstructionImpl.getWrappedProcessingInstruction();
101 }
102 else if (o instanceof QName) {
103 QNameImpl qNameImpl = (QNameImpl)o;
104
105 return (F)qNameImpl.getWrappedQName();
106 }
107 else if (o instanceof Text) {
108 TextImpl textImpl = (TextImpl)o;
109
110 return (F)textImpl.getWrappedText();
111 }
112 else if (o instanceof XPath) {
113 XPathImpl xPathImpl = (XPathImpl)o;
114
115 return (F)xPathImpl.getWrappedXPath();
116 }
117 else if (o instanceof Branch) {
118 BranchImpl branchImpl = (BranchImpl)o;
119
120 return (F)branchImpl.getWrappedBranch();
121 }
122 else if (o instanceof Node) {
123 NodeImpl nodeImpl = (NodeImpl)o;
124
125 return (F)nodeImpl.getWrappedNode();
126 }
127
128 throw new IllegalArgumentException(o.getClass().getName());
129 }
130
131 }