Package com.adobe.xmp

Examples of com.adobe.xmp.XMPException


        continue// The caller ensured the value is "Resource".
              // Ignore all rdf:ID attributes.
      }
      else
      {
        throw new XMPException("Invalid attribute for ParseTypeResource property element",
            BADRDF);
      }
    }

    rdf_PropertyElementList (xmp, newStruct, xmlNode, false);
View Full Code Here


   *
   * @throws XMPException thown on parsing errors
   */
  private static void rdf_ParseTypeCollectionPropertyElement() throws XMPException
  {
    throw new XMPException("ParseTypeCollection property element not allowed", BADXMP);
  }
View Full Code Here

   *
   * @throws XMPException thown on parsing errors
   */
  private static void rdf_ParseTypeOtherPropertyElement() throws XMPException
  {
    throw new XMPException("ParseTypeOther property element not allowed", BADXMP);
  }
View Full Code Here

   
    Node valueNode = null// ! Can come from rdf:value or rdf:resource.
   
    if (xmlNode.hasChildNodes())
    {
      throw new XMPException(
          "Nested content not allowed with rdf:resource or property attributes",
          BADRDF);
    }
   
    // First figure out what XMP this maps to and remember the XML node for a simple value.
    for (int i = 0; i < xmlNode.getAttributes().getLength(); i++)
    {
      Node attribute = xmlNode.getAttributes().item(i);
      if ("xmlns".equals(attribute.getPrefix())  ||
          (attribute.getPrefix() == null  &&  "xmlns".equals(attribute.getNodeName())))
      {
        continue;
      }
     
      int attrTerm = getRDFTermKind (attribute);

      switch (attrTerm)
      {
        case RDFTERM_ID :
          // Nothing to do.
          break;

        case RDFTERM_RESOURCE :
          if (hasNodeIDAttr)
          {
            throw new XMPException(
              "Empty property element can't have both rdf:resource and rdf:nodeID",
              BADRDF);
          }
          else if (hasValueAttr)
          {
            throw new XMPException(
                "Empty property element can't have both rdf:value and rdf:resource",
                BADXMP);
          }

          hasResourceAttr = true;
          if (!hasValueAttr)
          {
            valueNode = attribute;
         
          break;

        case RDFTERM_NODE_ID:
        if (hasResourceAttr)
        {
          throw new XMPException(
              "Empty property element can't have both rdf:resource and rdf:nodeID",
              BADRDF);
        }
        hasNodeIDAttr = true;
        break;

      case RDFTERM_OTHER:
        if ("value".equals(attribute.getLocalName())
            && NS_RDF.equals(attribute.getNamespaceURI()))
        {
          if (hasResourceAttr)
          {
            throw new XMPException(
                "Empty property element can't have both rdf:value and rdf:resource",
                BADXMP);
          }
          hasValueAttr = true;
          valueNode = attribute;
        }
        else if (!XML_LANG.equals(attribute.getNodeName()))
        {
          hasPropertyAttrs = true;
        }
        break;

      default:
        throw new XMPException("Unrecognized attribute of empty property element",
            BADRDF);
      }
    }
   
    // Create the right kind of child node and visit the attributes again
    // to add the fields or qualifiers.
    // ! Because of implementation vagaries,
    //   the xmpParent is the tree root for top level properties.
    // ! The schema is found, created if necessary, by addChildNode.
   
    XMPNode childNode = addChildNode(xmp, xmpParent, xmlNode, "", isTopLevel);
    boolean childIsStruct = false;
   
    if (hasValueAttr || hasResourceAttr)
    {
      childNode.setValue(valueNode != null ? valueNode.getNodeValue() : "");
      if (!hasValueAttr)
      {
        // ! Might have both rdf:value and rdf:resource.
        childNode.getOptions().setURI(true)
      }
    }
    else if (hasPropertyAttrs)
    {
      childNode.getOptions().setStruct(true);
      childIsStruct = true;
    }
   
    for (int i = 0; i < xmlNode.getAttributes().getLength(); i++)
    {
      Node attribute = xmlNode.getAttributes().item(i);
      if (attribute == valueNode  ||
        "xmlns".equals(attribute.getPrefix())  ||
        (attribute.getPrefix() == null  &&  "xmlns".equals(attribute.getNodeName())))
      {
        continue// Skip the rdf:value or rdf:resource attribute holding the value.
      }
     
      int attrTerm = getRDFTermKind (attribute);

      switch (attrTerm)
      {
        case RDFTERM_ID :
        case RDFTERM_NODE_ID :
          break// Ignore all rdf:ID and rdf:nodeID attributes.
         
        case RDFTERM_RESOURCE :
          addQualifierNode(childNode, "rdf:resource", attribute.getNodeValue());
          break;

        case RDFTERM_OTHER :
          if (!childIsStruct)
          {
            addQualifierNode(
              childNode, attribute.getNodeName(), attribute.getNodeValue());
          }
          else if (XML_LANG.equals(attribute.getNodeName()))
          {
            addQualifierNode (childNode, XML_LANG, attribute.getNodeValue());
          }
          else
          {
            addChildNode (xmp, childNode, attribute, attribute.getNodeValue(), false);
          }
          break;

        default :
          throw new XMPException("Unrecognized attribute of empty property element",
            BADRDF);
      }

    }   
  }
View Full Code Here

      }
      childName = prefix + xmlNode.getLocalName();
    }
    else
    {
      throw new XMPException(
        "XML namespace required for all elements and attributes", BADRDF);
    }

   
    // create schema node if not already there
    PropertyOptions childOptions = new PropertyOptions();
    boolean isAlias = false;
    if (isTopLevel)
    {
      // Lookup the schema node, adjust the XMP parent pointer.
      // Incoming parent must be the tree root.
      XMPNode schemaNode = XMPNodeUtils.findSchemaNode(xmp.getRoot(), namespace,
        DEFAULT_PREFIX, true);
      schemaNode.setImplicit(false)// Clear the implicit node bit.
      // need runtime check for proper 32 bit code.
      xmpParent = schemaNode;
     
      // If this is an alias set the alias flag in the node
      // and the hasAliases flag in the tree.
      if (registry.findAlias(childName) != null)
      {
        isAlias = true;
        xmp.getRoot().setHasAliases(true);
        schemaNode.setHasAliases(true);
      }
    }

   
    // Make sure that this is not a duplicate of a named node.
    boolean isArrayItem  = "rdf:li".equals(childName);
    boolean isValueNode  = "rdf:value".equals(childName);

    // Create XMP node and so some checks
    XMPNode newChild = new XMPNode(
      childName, value, childOptions);
    newChild.setAlias(isAlias);
   
    // Add the new child to the XMP parent node, a value node first.
    if (!isValueNode)
    {
      xmpParent.addChild(newChild);
    }
    else
    {
      xmpParent.addChild(1, newChild);
    }
   
   
    if (isValueNode)
    {
      if (isTopLevel  ||  !xmpParent.getOptions().isStruct())
      {
        throw new XMPException("Misplaced rdf:value element", BADRDF);
     
      xmpParent.setHasValueChild(true);
    }
   
    if (isArrayItem)
    {
      if (!xmpParent.getOptions().isArray())
      {
        throw new XMPException("Misplaced rdf:li element", BADRDF);
     
      newChild.setName(ARRAY_ITEM_NAME);
    }
   
    return newChild;
View Full Code Here

    // Intra-group duplicates are caught by XMPNode#addChild(...).
    if (valueNode.getOptions().getHasLanguage())
    {
      if (xmpParent.getOptions().getHasLanguage())
      {
        throw new XMPException("Redundant xml:lang for rdf:value element",
          BADXMP);
      }
      XMPNode langQual = valueNode.getQualifier(1);
      valueNode.removeQualifier(langQual);
      xmpParent.addQualifier(langQual);
View Full Code Here

TOP

Related Classes of com.adobe.xmp.XMPException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.