Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D2CD71784C for ; Mon, 6 Apr 2015 17:11:02 +0000 (UTC) Received: (qmail 20530 invoked by uid 500); 6 Apr 2015 17:10:57 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 20409 invoked by uid 500); 6 Apr 2015 17:10:57 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 19182 invoked by uid 99); 6 Apr 2015 17:10:56 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Apr 2015 17:10:56 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id CC8A0AC0B09 for ; Mon, 6 Apr 2015 17:10:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1671596 [21/46] - in /chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings: ./ css/ images/ images/logos/ xref-test/ xref-test/org/ xref-test/org/apache/ xref-test/org/apache/chemistry... Date: Mon, 06 Apr 2015 17:10:52 -0000 To: commits@chemistry.apache.org From: gabriele@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150406171056.CC8A0AC0B09@hades.apache.org> Added: chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomPubParser.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomPubParser.html?rev=1671596&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomPubParser.html (added) +++ chemistry/site/trunk/content/java/0.13.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomPubParser.html Mon Apr 6 17:10:50 2015 @@ -0,0 +1,567 @@ + + + + +AtomPubParser xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.client.bindings.spi.atompub;
+20  
+21  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.CONTENT_SRC;
+22  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.LINK_HREF;
+23  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.LINK_REL;
+24  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.LINK_TYPE;
+25  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_ACL;
+26  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_ALLOWABLEACTIONS;
+27  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_CHILDREN;
+28  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_COLLECTION;
+29  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_COLLECTION_TYPE;
+30  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_CONTENT;
+31  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_ENTRY;
+32  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_FEED;
+33  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_HTML;
+34  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_LINK;
+35  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_NUM_ITEMS;
+36  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_OBJECT;
+37  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_PATH_SEGMENT;
+38  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_RELATIVE_PATH_SEGMENT;
+39  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_REPOSITORY_INFO;
+40  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_SERVICE;
+41  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_TEMPLATE_TEMPLATE;
+42  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_TEMPLATE_TYPE;
+43  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_TYPE;
+44  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_URI_TEMPLATE;
+45  import static org.apache.chemistry.opencmis.client.bindings.spi.atompub.CmisAtomPubConstants.TAG_WORKSPACE;
+46  
+47  import java.io.InputStream;
+48  import java.math.BigInteger;
+49  import java.util.HashMap;
+50  import java.util.Map;
+51  
+52  import javax.xml.namespace.QName;
+53  import javax.xml.stream.XMLStreamException;
+54  import javax.xml.stream.XMLStreamReader;
+55  
+56  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomAcl;
+57  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomAllowableActions;
+58  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomBase;
+59  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomElement;
+60  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomEntry;
+61  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomFeed;
+62  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomLink;
+63  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.HtmlDoc;
+64  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.RepositoryWorkspace;
+65  import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.ServiceDoc;
+66  import org.apache.chemistry.opencmis.commons.data.ObjectData;
+67  import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+68  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+69  import org.apache.chemistry.opencmis.commons.impl.IOUtils;
+70  import org.apache.chemistry.opencmis.commons.impl.XMLConstants;
+71  import org.apache.chemistry.opencmis.commons.impl.XMLConstraints;
+72  import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
+73  import org.apache.chemistry.opencmis.commons.impl.XMLUtils;
+74  
+75  /**
+76   * AtomPub Parser.
+77   */
+78  public class AtomPubParser {
+79  
+80      // public constants
+81      public static final String LINK_REL_CONTENT = "@@content@@";
+82  
+83      private final InputStream stream;
+84      private AtomBase parseResult;
+85  
+86      public AtomPubParser(InputStream stream) {
+87          if (stream == null) {
+88              throw new IllegalArgumentException("No stream.");
+89          }
+90  
+91          this.stream = stream;
+92      }
+93  
+94      /**
+95       * Parses the stream.
+96       */
+97      public void parse() throws XMLStreamException {
+98          XMLStreamReader parser = XMLUtils.createParser(stream);
+99  
+100         try {
+101             while (true) {
+102                 int event = parser.getEventType();
+103                 if (event == XMLStreamReader.START_ELEMENT) {
+104                     QName name = parser.getName();
+105 
+106                     if (XMLConstants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
+107                         if (TAG_FEED.equals(name.getLocalPart())) {
+108                             parseResult = parseFeed(parser);
+109                             break;
+110                         } else if (TAG_ENTRY.equals(name.getLocalPart())) {
+111                             parseResult = parseEntry(parser);
+112                             break;
+113                         }
+114                     } else if (XMLConstants.NAMESPACE_CMIS.equals(name.getNamespaceURI())) {
+115                         if (TAG_ALLOWABLEACTIONS.equals(name.getLocalPart())) {
+116                             parseResult = parseAllowableActions(parser);
+117                             break;
+118                         } else if (TAG_ACL.equals(name.getLocalPart())) {
+119                             parseResult = parseACL(parser);
+120                             break;
+121                         }
+122                     } else if (XMLConstants.NAMESPACE_APP.equals(name.getNamespaceURI())) {
+123                         if (TAG_SERVICE.equals(name.getLocalPart())) {
+124                             parseResult = parseServiceDoc(parser);
+125                             break;
+126                         }
+127                     } else if (TAG_HTML.equalsIgnoreCase(name.getLocalPart())) {
+128                         parseResult = new HtmlDoc();
+129                         break;
+130                     }
+131                 }
+132 
+133                 if (!XMLUtils.next(parser)) {
+134                     break;
+135                 }
+136             }
+137 
+138         } finally {
+139             try {
+140                 parser.close();
+141             } catch (XMLStreamException xse) {
+142                 // there is nothing we can do
+143             }
+144 
+145             // make sure the stream is read and closed in all cases
+146             IOUtils.consumeAndClose(stream);
+147         }
+148     }
+149 
+150     /**
+151      * Return the parse results.
+152      */
+153     public AtomBase getResults() {
+154         return parseResult;
+155     }
+156 
+157     /**
+158      * Parses a service document.
+159      */
+160     private static ServiceDoc parseServiceDoc(XMLStreamReader parser) throws XMLStreamException {
+161         ServiceDoc result = new ServiceDoc();
+162 
+163         XMLUtils.next(parser);
+164 
+165         while (true) {
+166             int event = parser.getEventType();
+167             if (event == XMLStreamReader.START_ELEMENT) {
+168                 QName name = parser.getName();
+169 
+170                 if (XMLConstants.NAMESPACE_APP.equals(name.getNamespaceURI())) {
+171                     if (TAG_WORKSPACE.equals(name.getLocalPart())) {
+172                         result.addWorkspace(parseWorkspace(parser));
+173                     } else {
+174                         XMLUtils.skip(parser);
+175                     }
+176                 } else {
+177                     XMLUtils.skip(parser);
+178                 }
+179             } else if (event == XMLStreamReader.END_ELEMENT) {
+180                 break;
+181             } else {
+182                 if (!XMLUtils.next(parser)) {
+183                     break;
+184                 }
+185             }
+186         }
+187 
+188         return result;
+189     }
+190 
+191     /**
+192      * Parses a workspace element in a service document.
+193      */
+194     private static RepositoryWorkspace parseWorkspace(XMLStreamReader parser) throws XMLStreamException {
+195         RepositoryWorkspace workspace = new RepositoryWorkspace();
+196 
+197         XMLUtils.next(parser);
+198 
+199         while (true) {
+200             int event = parser.getEventType();
+201             if (event == XMLStreamReader.START_ELEMENT) {
+202                 AtomElement element = parseWorkspaceElement(parser);
+203 
+204                 // check if we can extract the workspace id
+205                 if ((element != null) && (element.getObject() instanceof RepositoryInfo)) {
+206                     workspace.setId(((RepositoryInfo) element.getObject()).getId());
+207                 }
+208 
+209                 // add to workspace
+210                 workspace.addElement(element);
+211             } else if (event == XMLStreamReader.END_ELEMENT) {
+212                 break;
+213             } else {
+214                 if (!XMLUtils.next(parser)) {
+215                     break;
+216                 }
+217             }
+218         }
+219 
+220         XMLUtils.next(parser);
+221 
+222         return workspace;
+223     }
+224 
+225     /**
+226      * Parses an Atom feed.
+227      */
+228     private AtomFeed parseFeed(XMLStreamReader parser) throws XMLStreamException {
+229         AtomFeed result = new AtomFeed();
+230 
+231         XMLUtils.next(parser);
+232 
+233         while (true) {
+234             int event = parser.getEventType();
+235             if (event == XMLStreamReader.START_ELEMENT) {
+236                 QName name = parser.getName();
+237 
+238                 if (XMLConstants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
+239                     if (TAG_LINK.equals(name.getLocalPart())) {
+240                         result.addElement(parseLink(parser));
+241                     } else if (TAG_ENTRY.equals(name.getLocalPart())) {
+242                         result.addEntry(parseEntry(parser));
+243                     } else {
+244                         XMLUtils.skip(parser);
+245                     }
+246                 } else if (XMLConstants.NAMESPACE_RESTATOM.equals(name.getNamespaceURI())) {
+247                     if (TAG_NUM_ITEMS.equals(name.getLocalPart())) {
+248                         result.addElement(parseBigInteger(parser));
+249                     } else {
+250                         XMLUtils.skip(parser);
+251                     }
+252                 } else if (XMLConstants.NAMESPACE_APACHE_CHEMISTRY.equals(name.getNamespaceURI())) {
+253                     result.addElement(parseText(parser));
+254                 } else {
+255                     XMLUtils.skip(parser);
+256                 }
+257             } else if (event == XMLStreamReader.END_ELEMENT) {
+258                 break;
+259             } else {
+260                 if (!XMLUtils.next(parser)) {
+261                     break;
+262                 }
+263             }
+264         }
+265 
+266         XMLUtils.next(parser);
+267 
+268         return result;
+269     }
+270 
+271     /**
+272      * Parses an Atom entry.
+273      */
+274     private AtomEntry parseEntry(XMLStreamReader parser) throws XMLStreamException {
+275         AtomEntry result = new AtomEntry();
+276 
+277         XMLUtils.next(parser);
+278 
+279         // walk through all tags in entry
+280         while (true) {
+281             int event = parser.getEventType();
+282             if (event == XMLStreamReader.START_ELEMENT) {
+283                 AtomElement element = parseElement(parser);
+284                 if (element != null) {
+285                     // add to entry
+286                     result.addElement(element);
+287 
+288                     // find and set object id
+289                     if (element.getObject() instanceof ObjectData) {
+290                         result.setId(((ObjectData) element.getObject()).getId());
+291                     } else if (element.getObject() instanceof TypeDefinition) {
+292                         result.setId(((TypeDefinition) element.getObject()).getId());
+293                     }
+294                 }
+295             } else if (event == XMLStreamReader.END_ELEMENT) {
+296                 break;
+297             } else {
+298                 if (!XMLUtils.next(parser)) {
+299                     break;
+300                 }
+301             }
+302         }
+303 
+304         XMLUtils.next(parser);
+305 
+306         return result;
+307     }
+308 
+309     /**
+310      * Parses an Allowable Actions document.
+311      */
+312     private static AtomAllowableActions parseAllowableActions(XMLStreamReader parser) throws XMLStreamException {
+313         return new AtomAllowableActions(XMLConverter.convertAllowableActions(parser));
+314     }
+315 
+316     /**
+317      * Parses an ACL document.
+318      */
+319     private static AtomAcl parseACL(XMLStreamReader parser) throws XMLStreamException {
+320         return new AtomAcl(XMLConverter.convertAcl(parser));
+321     }
+322 
+323     /**
+324      * Parses an element.
+325      */
+326     private AtomElement parseElement(XMLStreamReader parser) throws XMLStreamException {
+327         QName name = parser.getName();
+328 
+329         if (XMLConstants.NAMESPACE_RESTATOM.equals(name.getNamespaceURI())) {
+330             if (TAG_OBJECT.equals(name.getLocalPart())) {
+331                 return new AtomElement(name, XMLConverter.convertObject(parser));
+332             } else if (TAG_PATH_SEGMENT.equals(name.getLocalPart())
+333                     || TAG_RELATIVE_PATH_SEGMENT.equals(name.getLocalPart())) {
+334                 return parseText(parser);
+335             } else if (TAG_TYPE.equals(name.getLocalPart())) {
+336                 return new AtomElement(name, XMLConverter.convertTypeDefinition(parser));
+337             } else if (TAG_CHILDREN.equals(name.getLocalPart())) {
+338                 return parseChildren(parser);
+339             }
+340         } else if (XMLConstants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
+341             if (TAG_LINK.equals(name.getLocalPart())) {
+342                 return parseLink(parser);
+343             } else if (TAG_CONTENT.equals(name.getLocalPart())) {
+344                 return parseAtomContentSrc(parser);
+345             }
+346         }
+347 
+348         // we don't know it - skip it
+349         XMLUtils.skip(parser);
+350 
+351         return null;
+352     }
+353 
+354     /**
+355      * Parses a children element.
+356      */
+357     private AtomElement parseChildren(XMLStreamReader parser) throws XMLStreamException {
+358         AtomElement result = null;
+359         QName childName = parser.getName();
+360 
+361         XMLUtils.next(parser);
+362 
+363         // walk through the children tag
+364         while (true) {
+365             int event = parser.getEventType();
+366             if (event == XMLStreamReader.START_ELEMENT) {
+367                 QName name = parser.getName();
+368 
+369                 if (XMLConstants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
+370                     if (TAG_FEED.equals(name.getLocalPart())) {
+371                         result = new AtomElement(childName, parseFeed(parser));
+372                     } else {
+373                         XMLUtils.skip(parser);
+374                     }
+375                 } else {
+376                     XMLUtils.skip(parser);
+377                 }
+378             } else if (event == XMLStreamReader.END_ELEMENT) {
+379                 break;
+380             } else {
+381                 if (!XMLUtils.next(parser)) {
+382                     break;
+383                 }
+384             }
+385         }
+386 
+387         XMLUtils.next(parser);
+388 
+389         return result;
+390     }
+391 
+392     /**
+393      * Parses a workspace element.
+394      */
+395     private static AtomElement parseWorkspaceElement(XMLStreamReader parser) throws XMLStreamException {
+396         QName name = parser.getName();
+397 
+398         if (XMLConstants.NAMESPACE_RESTATOM.equals(name.getNamespaceURI())) {
+399             if (TAG_REPOSITORY_INFO.equals(name.getLocalPart())) {
+400                 return new AtomElement(name, XMLConverter.convertRepositoryInfo(parser));
+401             } else if (TAG_URI_TEMPLATE.equals(name.getLocalPart())) {
+402                 return parseTemplate(parser);
+403             }
+404         } else if (XMLConstants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
+405             if (TAG_LINK.equals(name.getLocalPart())) {
+406                 return parseLink(parser);
+407             }
+408         } else if (XMLConstants.NAMESPACE_APP.equals(name.getNamespaceURI())) {
+409             if (TAG_COLLECTION.equals(name.getLocalPart())) {
+410                 return parseCollection(parser);
+411             }
+412         }
+413 
+414         // we don't know it - skip it
+415         XMLUtils.skip(parser);
+416 
+417         return null;
+418     }
+419 
+420     /**
+421      * Parses a collection tag.
+422      */
+423     private static AtomElement parseCollection(XMLStreamReader parser) throws XMLStreamException {
+424         QName name = parser.getName();
+425         Map<String, String> result = new HashMap<String, String>();
+426 
+427         result.put("href", parser.getAttributeValue(null, "href"));
+428 
+429         XMLUtils.next(parser);
+430 
+431         while (true) {
+432             int event = parser.getEventType();
+433             if (event == XMLStreamReader.START_ELEMENT) {
+434                 QName tagName = parser.getName();
+435                 if (XMLConstants.NAMESPACE_RESTATOM.equals(tagName.getNamespaceURI())
+436                         && TAG_COLLECTION_TYPE.equals(tagName.getLocalPart())) {
+437                     result.put("collectionType", XMLUtils.readText(parser, XMLConstraints.MAX_STRING_LENGTH));
+438                 } else {
+439                     XMLUtils.skip(parser);
+440                 }
+441             } else if (event == XMLStreamReader.END_ELEMENT) {
+442                 break;
+443             } else {
+444                 if (!XMLUtils.next(parser)) {
+445                     break;
+446                 }
+447             }
+448         }
+449 
+450         XMLUtils.next(parser);
+451 
+452         return new AtomElement(name, result);
+453     }
+454 
+455     /**
+456      * Parses a template tag.
+457      */
+458     private static AtomElement parseTemplate(XMLStreamReader parser) throws XMLStreamException {
+459         QName name = parser.getName();
+460         Map<String, String> result = new HashMap<String, String>();
+461 
+462         XMLUtils.next(parser);
+463 
+464         while (true) {
+465             int event = parser.getEventType();
+466             if (event == XMLStreamReader.START_ELEMENT) {
+467                 QName tagName = parser.getName();
+468                 if (XMLConstants.NAMESPACE_RESTATOM.equals(tagName.getNamespaceURI())) {
+469                     if (TAG_TEMPLATE_TEMPLATE.equals(tagName.getLocalPart())) {
+470                         result.put("template", XMLUtils.readText(parser, XMLConstraints.MAX_STRING_LENGTH));
+471                     } else if (TAG_TEMPLATE_TYPE.equals(tagName.getLocalPart())) {
+472                         result.put("type", XMLUtils.readText(parser, XMLConstraints.MAX_STRING_LENGTH));
+473                     } else {
+474                         XMLUtils.skip(parser);
+475                     }
+476                 } else {
+477                     XMLUtils.skip(parser);
+478                 }
+479             } else if (event == XMLStreamReader.END_ELEMENT) {
+480                 break;
+481             } else {
+482                 if (!XMLUtils.next(parser)) {
+483                     break;
+484                 }
+485             }
+486         }
+487 
+488         XMLUtils.next(parser);
+489 
+490         return new AtomElement(name, result);
+491     }
+492 
+493     /**
+494      * Parses a link tag.
+495      */
+496     private static AtomElement parseLink(XMLStreamReader parser) throws XMLStreamException {
+497         QName name = parser.getName();
+498         AtomLink result = new AtomLink();
+499 
+500         // save attributes
+501         for (int i = 0; i < parser.getAttributeCount(); i++) {
+502             if (LINK_REL.equals(parser.getAttributeLocalName(i))) {
+503                 result.setRel(parser.getAttributeValue(i));
+504             } else if (LINK_HREF.equals(parser.getAttributeLocalName(i))) {
+505                 result.setHref(parser.getAttributeValue(i));
+506             } else if (LINK_TYPE.equals(parser.getAttributeLocalName(i))) {
+507                 result.setType(parser.getAttributeValue(i));
+508             }
+509         }
+510 
+511         // skip enclosed tags, if any
+512         XMLUtils.skip(parser);
+513 
+514         return new AtomElement(name, result);
+515     }
+516 
+517     /**
+518      * Parses a link tag.
+519      */
+520     private static AtomElement parseAtomContentSrc(XMLStreamReader parser) throws XMLStreamException {
+521         QName name = parser.getName();
+522         AtomLink result = new AtomLink();
+523         result.setRel(LINK_REL_CONTENT);
+524 
+525         // save attributes
+526         for (int i = 0; i < parser.getAttributeCount(); i++) {
+527             if (CONTENT_SRC.equals(parser.getAttributeLocalName(i))) {
+528                 result.setHref(parser.getAttributeValue(i));
+529             }
+530         }
+531 
+532         // skip enclosed tags, if any
+533         XMLUtils.skip(parser);
+534 
+535         return new AtomElement(name, result);
+536     }
+537 
+538     /**
+539      * Parses a text tag.
+540      */
+541     private static AtomElement parseText(XMLStreamReader parser) throws XMLStreamException {
+542         QName name = parser.getName();
+543         return new AtomElement(name, XMLUtils.readText(parser, XMLConstraints.MAX_STRING_LENGTH));
+544     }
+545 
+546     /**
+547      * Parses a text tag and convert it into an integer.
+548      */
+549     private static AtomElement parseBigInteger(XMLStreamReader parser) throws XMLStreamException {
+550         QName name = parser.getName();
+551         return new AtomElement(name, new BigInteger(XMLUtils.readText(parser, XMLConstraints.MAX_STRING_LENGTH)));
+552     }
+553 }
+
+
+ +