Package com.adobe.xmp

Examples of com.adobe.xmp.XMPException


    {
      // the string length is equal to the length of the UTF-8 encoding
      int minSize = outputStream.getBytesWritten() + tailLength * unicodeSize;
      if (minSize > padding)
      {
        throw new XMPException("Can't fit into specified packet size",
          XMPError.BADSERIALIZE);
      }
      padding -= minSize;  // Now the actual amount of padding to add.
    }

View Full Code Here


    if (options.getExactPacketLength())
    {
      if (options.getOmitPacketWrapper() | options.getIncludeThumbnailPad())
      {
        throw new XMPException("Inconsistent options for exact size serialize",
            XMPError.BADOPTIONS);
      }
      if ((options.getPadding() & (unicodeSize - 1)) != 0)
      {
        throw new XMPException("Exact size must be a multiple of the Unicode element",
            XMPError.BADOPTIONS);
      }
    }
    else if (options.getReadOnlyPacket())
    {
      if (options.getOmitPacketWrapper() | options.getIncludeThumbnailPad())
      {
        throw new XMPException("Inconsistent options for read-only packet",
            XMPError.BADOPTIONS);
      }
      padding = 0;
    }
    else if (options.getOmitPacketWrapper())
    {
      if (options.getIncludeThumbnailPad())
      {
        throw new XMPException("Inconsistent options for non-packet serialize",
            XMPError.BADOPTIONS);
      }
      padding = 0;
    }
    else
View Full Code Here

      }
    }
   
    if (hasRDFResourceQual && hasElemFields)
    {
      throw new XMPException(
          "Can't mix rdf:resource qualifier and element fields",
          XMPError.BADRDF);
    }

    if (!node.hasChildren())
View Full Code Here

      // ! The value is output by a recursive call ON THE SAME NODE with
      // emitAsRDFValue set.
 
      if (hasRDFResourceQual)
      {
        throw new XMPException("Can't mix rdf:resource and general qualifiers",
            XMPError.BADRDF);
      }
     
      // Change serialization to canonical format with inner rdf:Description-tag
      // depending on option
      if (useCanonicalRDF)
      {
        write(">");
        writeNewline();
   
        indent++;
        writeIndent(indent);
        write(RDF_STRUCT_START);
        write(">");
      }
      else
      {
        write(" rdf:parseType=\"Resource\">");
     
      writeNewline();
     
      serializeCanonicalRDFProperty(node, useCanonicalRDF, true, indent + 1);

      for (Iterator it = node.iterateQualifier(); it.hasNext();)
      {
        XMPNode qualifier = (XMPNode) it.next();
        if (!RDF_ATTR_QUALIFIER.contains(qualifier.getName()))
        {
          serializeCanonicalRDFProperty(qualifier, useCanonicalRDF, false, indent + 1);
        }
      }

      if (useCanonicalRDF)
      { 
        writeIndent(indent);
        write(RDF_STRUCT_END);
        writeNewline();
        indent--;
     
    }
    else
    {
      // This node has no general qualifiers. Emit using an unqualified form.
     
      if (!node.getOptions().isCompositeProperty())
      {
        // This is a simple property.
       
        if (node.getOptions().isURI())
        {
          write(" rdf:resource=\"");
          appendNodeValue(node.getValue(), true);
          write("\"/>");
          writeNewline();
          emitEndTag = false;
        }
        else if (node.getValue() == null ||  "".equals(node.getValue()))
        {
          write("/>");
          writeNewline();
          emitEndTag = false;
        }
        else
        {
          write('>');
          appendNodeValue(node.getValue(), false);
          indentEndTag = false;
        }
      }
      else if (node.getOptions().isArray())
      {
        // This is an array.
        write('>');
        writeNewline();
        emitRDFArrayTag(node, true, indent + 1);
        if (node.getOptions().isArrayAltText())
        {
          XMPNodeUtils.normalizeLangArray(node);
        }
        for (Iterator it = node.iterateChildren(); it.hasNext();)
        {
          XMPNode child = (XMPNode) it.next();
          serializeCanonicalRDFProperty(child, useCanonicalRDF, false,  indent + 2);
        }
        emitRDFArrayTag(node, false, indent + 1);
     
     
      }
      else if (!hasRDFResourceQual)
      {
        // This is a "normal" struct, use the rdf:parseType="Resource" form.
        if (!node.hasChildren())
        {
          // Change serialization to canonical format with inner rdf:Description-tag
          // if option is set
          if (useCanonicalRDF)
          {
            write(">");
            writeNewline();
            writeIndent(indent + 1);
            write(RDF_EMPTY_STRUCT);
          }
          else
          {
            write(" rdf:parseType=\"Resource\"/>");
            emitEndTag = false;
         
          writeNewline();
        }
        else
        {
          // Change serialization to canonical format with inner rdf:Description-tag
          // if option is set
          if (useCanonicalRDF)
          { 
            write(">");
            writeNewline();
            indent++;
            writeIndent(indent);
            write(RDF_STRUCT_START);
            write(">");
          }
          else
          {
            write(" rdf:parseType=\"Resource\">");
         
          writeNewline();
         
          for (Iterator it = node.iterateChildren(); it.hasNext();)
          {
            XMPNode child = (XMPNode) it.next();
            serializeCanonicalRDFProperty(child, useCanonicalRDF, false, indent + 1);
          }
         
          if (useCanonicalRDF)
          { 
            writeIndent(indent);
            write(RDF_STRUCT_END);
            writeNewline();
            indent--;
         
        }
      }
      else
      {
        // This is a struct with an rdf:resource attribute, use the
        // "empty property element" form.
        for (Iterator it = node.iterateChildren(); it.hasNext();)
        {
          XMPNode child = (XMPNode) it.next();
          if (!canBeRDFAttrProp(child))
          {
            throw new XMPException("Can't mix rdf:resource and complex fields",
                XMPError.BADRDF);
          }
          writeNewline();
          writeIndent(indent + 1);
          write(' ');
View Full Code Here

      startNode = XMPNodeUtils.findSchemaNode(xmp.getRoot(), schemaNS, false);
    }
    else // !baseSchema  &&  baseProperty
    {
      // No schema but property provided -> error
      throw new XMPException("Schema namespace URI is required", XMPError.BADSCHEMA);
    }     

   
    // create iterator
    if (startNode != null)
View Full Code Here

          idNode.removeQualifiers();   
          tree.setName(null);
        }
        else
       
          throw new XMPException("Failure creating xmpMM:InstanceID",
              XMPError.INTERNALFAILURE);
       
      }
    }   
  }
View Full Code Here

  {
    if (baseArray.getOptions().isArrayAltText())
    {
      if (childNode.getOptions().getHasLanguage())
      {
        throw new XMPException("Alias to x-default already has a language qualifier",
            XMPError.BADXMP);
      }
     
      XMPNode langQual = new XMPNode(XMPConst.XML_LANG, XMPConst.X_DEFAULT, null);
      childNode.addQualifier(langQual);
View Full Code Here

      boolean outerCall) throws XMPException
  {
    if (!aliasNode.getValue().equals(baseNode.getValue())  ||
      aliasNode.getChildrenLength() != baseNode.getChildrenLength())
    {
      throw new XMPException("Mismatch between alias and base nodes", XMPError.BADXMP);
    }
   
    if (
        !outerCall  &&
        (!aliasNode.getName().equals(baseNode.getName())  ||
         !aliasNode.getOptions().equals(baseNode.getOptions())  ||
         aliasNode.getQualifierLength() != baseNode.getQualifierLength())
       )
      {
      throw new XMPException("Mismatch between alias and base nodes",
        XMPError.BADXMP);
    }
   
    for (Iterator an = aliasNode.iterateChildren(),
            bn = baseNode.iterateChildren();
View Full Code Here

   */
  public static XMPPath expandXPath(String schemaNS, String path) throws XMPException
  {
    if (schemaNS == null  ||  path == null)
    {
      throw new XMPException("Parameter must not be null", XMPError.BADPARAM);
    }

    XMPPath expandedXPath = new XMPPath();
    PathPosition pos = new PathPosition();
    pos.path = path;
   
    // Pull out the first component and do some special processing on it: add the schema
    // namespace prefix and and see if it is an alias. The start must be a "qualName".
    parseRootNode(schemaNS, pos, expandedXPath);

    // Now continue to process the rest of the XMPPath string.
    while (pos.stepEnd < path.length())
    {
      pos.stepBegin = pos.stepEnd;
     
      skipPathDelimiter(path, pos);

      pos.stepEnd = pos.stepBegin;

     
      XMPPathSegment segment;
      if (path.charAt(pos.stepBegin) != '[')
      {
        // A struct field or qualifier.
        segment = parseStructSegment(pos);
      }
      else
      {
        // One of the array forms.
        segment = parseIndexSegment(pos);
      }
     

      if (segment.getKind() == XMPPath.STRUCT_FIELD_STEP)
      {
        if (segment.getName().charAt(0) == '@')
        {
          segment.setName("?" + segment.getName().substring(1));
          if (!"?xml:lang".equals(segment.getName()))
          {
            throw new XMPException("Only xml:lang allowed with '@'",
                XMPError.BADXPATH);
          }
        }
        if (segment.getName().charAt(0) == '?')
        {
          pos.nameStart++;
          segment.setKind(XMPPath.QUALIFIER_STEP);
        }

        verifyQualName(pos.path.substring(pos.nameStart, pos.nameEnd));
      }
      else if (segment.getKind() == XMPPath.FIELD_SELECTOR_STEP)
      {
        if (segment.getName().charAt(1) == '@')
        {
          segment.setName("[?" + segment.getName().substring(2));
          if (!segment.getName().startsWith("[?xml:lang="))
          {
            throw new XMPException("Only xml:lang allowed with '@'",
                XMPError.BADXPATH);
          }
        }

        if (segment.getName().charAt(1) == '?')
View Full Code Here

      pos.stepBegin++;

      // added for Java
      if (pos.stepBegin >= path.length())
      {
        throw new XMPException("Empty XMPPath segment", XMPError.BADXPATH);
      }
    }

    if (path.charAt(pos.stepBegin) == '*')
    {
      // skip asterisk

      pos.stepBegin++;
      if (pos.stepBegin >= path.length() || path.charAt(pos.stepBegin) != '[')
      {
        throw new XMPException("Missing '[' after '*'", XMPError.BADXPATH);
      }
    }
  }
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.