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 @Override
044 protected TranslatedList<E, F> newInstance(
045 List<E> newList, List<F> oldList) {
046
047 return new NodeList<E, F>(newList, oldList);
048 }
049
050 @Override
051 protected F toOldObject(E o) {
052 if (o instanceof Attribute) {
053 AttributeImpl attributeImpl = (AttributeImpl)o;
054
055 return (F)attributeImpl.getWrappedAttribute();
056 }
057 else if (o instanceof CDATA) {
058 CDATAImpl cdataImpl = (CDATAImpl)o;
059
060 return (F)cdataImpl.getWrappedCDATA();
061 }
062 else if (o instanceof Comment) {
063 CommentImpl commentImpl = (CommentImpl)o;
064
065 return (F)commentImpl.getWrappedComment();
066 }
067 else if (o instanceof Document) {
068 DocumentImpl documentImpl = (DocumentImpl)o;
069
070 return (F)documentImpl.getWrappedDocument();
071 }
072 else if (o instanceof Element) {
073 ElementImpl elementImpl = (ElementImpl)o;
074
075 return (F)elementImpl.getWrappedElement();
076 }
077 else if (o instanceof Entity) {
078 EntityImpl entityImpl = (EntityImpl)o;
079
080 return (F)entityImpl.getWrappedEntity();
081 }
082 else if (o instanceof Namespace) {
083 NamespaceImpl namespaceImpl = (NamespaceImpl)o;
084
085 return (F)namespaceImpl.getWrappedNamespace();
086 }
087 else if (o instanceof ProcessingInstruction) {
088 ProcessingInstructionImpl processingInstructionImpl =
089 (ProcessingInstructionImpl)o;
090
091 return
092 (F)processingInstructionImpl.getWrappedProcessingInstruction();
093 }
094 else if (o instanceof QName) {
095 QNameImpl qNameImpl = (QNameImpl)o;
096
097 return (F)qNameImpl.getWrappedQName();
098 }
099 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 }