001
014
015 package com.liferay.portal.xml;
016
017 import com.liferay.portal.kernel.util.TranslatedList;
018 import com.liferay.portal.kernel.xml.Attribute;
019 import com.liferay.portal.kernel.xml.Branch;
020 import com.liferay.portal.kernel.xml.CDATA;
021 import com.liferay.portal.kernel.xml.Comment;
022 import com.liferay.portal.kernel.xml.Document;
023 import com.liferay.portal.kernel.xml.Element;
024 import com.liferay.portal.kernel.xml.Entity;
025 import com.liferay.portal.kernel.xml.Namespace;
026 import com.liferay.portal.kernel.xml.Node;
027 import com.liferay.portal.kernel.xml.ProcessingInstruction;
028 import com.liferay.portal.kernel.xml.QName;
029 import com.liferay.portal.kernel.xml.Text;
030 import com.liferay.portal.kernel.xml.XPath;
031
032 import java.util.List;
033
034
037 public class NodeList<E, F> extends TranslatedList<E, F> {
038
039 public NodeList(List<E> newList, List<F> oldList) {
040 super(newList, oldList);
041 }
042
043 protected TranslatedList<E, F> newInstance(
044 List<E> newList, List<F> oldList) {
045
046 return new NodeList<E, F>(newList, oldList);
047 }
048
049 protected F toOldObject(E o) {
050 if (o instanceof Attribute) {
051 AttributeImpl attributeImpl = (AttributeImpl)o;
052
053 return (F)attributeImpl.getWrappedAttribute();
054 }
055 else if (o instanceof CDATA) {
056 CDATAImpl cdataImpl = (CDATAImpl)o;
057
058 return (F)cdataImpl.getWrappedCDATA();
059 }
060 else if (o instanceof Comment) {
061 CommentImpl commentImpl = (CommentImpl)o;
062
063 return (F)commentImpl.getWrappedComment();
064 }
065 else if (o instanceof Document) {
066 DocumentImpl documentImpl = (DocumentImpl)o;
067
068 return (F)documentImpl.getWrappedDocument();
069 }
070 else if (o instanceof Element) {
071 ElementImpl elementImpl = (ElementImpl)o;
072
073 return (F)elementImpl.getWrappedElement();
074 }
075 else if (o instanceof Entity) {
076 EntityImpl entityImpl = (EntityImpl)o;
077
078 return (F)entityImpl.getWrappedEntity();
079 }
080 else if (o instanceof Namespace) {
081 NamespaceImpl namespaceImpl = (NamespaceImpl)o;
082
083 return (F)namespaceImpl.getWrappedNamespace();
084 }
085 else if (o instanceof ProcessingInstruction) {
086 ProcessingInstructionImpl processingInstructionImpl =
087 (ProcessingInstructionImpl)o;
088
089 return
090 (F)processingInstructionImpl.getWrappedProcessingInstruction();
091 }
092 else if (o instanceof QName) {
093 QNameImpl qNameImpl = (QNameImpl)o;
094
095 return (F)qNameImpl.getWrappedQName();
096 }
097 else if (o instanceof Text) {
098 TextImpl textImpl = (TextImpl)o;
099
100 return (F)textImpl.getWrappedText();
101 }
102 else if (o instanceof XPath) {
103 XPathImpl xPathImpl = (XPathImpl)o;
104
105 return (F)xPathImpl.getWrappedXPath();
106 }
107 else if (o instanceof Branch) {
108 BranchImpl branchImpl = (BranchImpl)o;
109
110 return (F)branchImpl.getWrappedBranch();
111 }
112 else if (o instanceof Node) {
113 NodeImpl nodeImpl = (NodeImpl)o;
114
115 return (F)nodeImpl.getWrappedNode();
116 }
117
118 throw new IllegalArgumentException(o.getClass().getName());
119 }
120
121 }