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