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