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