Package com.itextpdf.xmp

Examples of com.itextpdf.xmp.XMPException


     
      outputStream.close();
    }
    catch (IOException e)
    {
      throw new XMPException("Error writing to the OutputStream", XMPError.UNKNOWN);
    }
  }
View Full Code Here


    {
      // 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

TOP

Related Classes of com.itextpdf.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.