Examples of XMPException


Examples of com.itextpdf.xmp.XMPException

   */
  public static XMPDateTime parse(String iso8601String, XMPDateTime binValue) throws XMPException
  {
    if (iso8601String == null)
    {
      throw new XMPException("Parameter must not be null", XMPError.BADPARAM);
    }
    else if (iso8601String.length() == 0)
    {
      return binValue;
    }
   
    ParseState input = new ParseState(iso8601String);
    int value;
   
    if (input.ch(0) == '-')
    {
      input.skip();
    }
   
    // Extract the year.
    value = input.gatherInt("Invalid year in date string", 9999);
    if (input.hasNext()  &&  input.ch() != '-')
    {
      throw new XMPException("Invalid date string, after year", XMPError.BADVALUE);
    }

    if (input.ch(0) == '-')
    {
      value = -value;
    }
    binValue.setYear(value);
    if (!input.hasNext())
    {
      return binValue;
    }
    input.skip();
   
   
    // Extract the month.
    value = input.gatherInt("Invalid month in date string", 12);
    if (input.hasNext()  &&  input.ch() != '-')
    {
      throw new XMPException("Invalid date string, after month", XMPError.BADVALUE);
    }
    binValue.setMonth(value);
    if (!input.hasNext())
    {
      return binValue;
    }
    input.skip();

   
    // Extract the day.
    value = input.gatherInt("Invalid day in date string", 31);
    if (input.hasNext()  &&  input.ch() != 'T')
    {
      throw new XMPException("Invalid date string, after day", XMPError.BADVALUE);
    }
    binValue.setDay(value);
    if (!input.hasNext())
    {
      return binValue;
    }
    input.skip();
   
    // Extract the hour.
    value = input.gatherInt("Invalid hour in date string", 23);
    binValue.setHour(value);
    if (!input.hasNext())
    {
      return binValue;
    }
   
    // Extract the minute.
    if (input.ch() == ':')
    { 
      input.skip();
      value = input.gatherInt("Invalid minute in date string", 59);
      if (input.hasNext()  &&
        input.ch() != ':' && input.ch() != 'Z' && input.ch() != '+' && input.ch() != '-')
      {
        throw new XMPException("Invalid date string, after minute", XMPError.BADVALUE);
      }
      binValue.setMinute(value);
    }
   
    if (!input.hasNext())
    {
      return binValue;
    }
    else if (input.hasNext()  &&  input.ch() == ':')
    {
      input.skip();
      value = input.gatherInt("Invalid whole seconds in date string", 59);
      if (input.hasNext()  &&  input.ch() != '.'  &&  input.ch() != 'Z'  &&
        input.ch() != '+' && input.ch() != '-')
      {
        throw new XMPException("Invalid date string, after whole seconds",
            XMPError.BADVALUE);
      }
      binValue.setSecond(value);
      if (input.ch() == '.')
      {
        input.skip();
        int digits = input.pos();
        value = input.gatherInt("Invalid fractional seconds in date string", 999999999);
        if (input.hasNext()  &&
          (input.ch() != 'Z'  &&  input.ch() != '+'  &&  input.ch() != '-'))
        {
          throw new XMPException("Invalid date string, after fractional second",
              XMPError.BADVALUE);
        }
        digits = input.pos() - digits;
        for (; digits > 9; --digits)
        { 
          value = value / 10;
       
        for (; digits < 9; ++digits)
        { 
          value = value * 10;
       
        binValue.setNanoSecond(value);
      }
    }
    else if (input.ch() != 'Z'  &&  input.ch() != '+'  &&  input.ch() != '-')
    {
      throw new XMPException("Invalid date string, after time", XMPError.BADVALUE);
    }

   
    int tzSign = 0;
    int tzHour = 0;
    int tzMinute = 0;
   
    if (!input.hasNext())
    {
      // no Timezone at all
      return binValue;
    }
    else if (input.ch() == 'Z')
    {
      input.skip();
    }
    else if (input.hasNext())
    {
      if (input.ch() == '+')
      {
        tzSign = 1;
      }
      else if (input.ch() == '-')
      {
        tzSign = -1;
      }
      else
      {
        throw new XMPException("Time zone must begin with 'Z', '+', or '-'",
            XMPError.BADVALUE);
      }

      input.skip();
      // Extract the time zone hour.
      tzHour = input.gatherInt("Invalid time zone hour in date string", 23);
      if (input.hasNext())
      {
        if (input.ch() == ':')
        {
          input.skip();
         
          // Extract the time zone minute.
          tzMinute = input.gatherInt("Invalid time zone minute in date string", 59);
       
        else
        {
          throw new XMPException("Invalid date string, after time zone hour",
            XMPError.BADVALUE);
        }
      } 
    }
   
    // create a corresponding TZ and set it time zone
    int offset = (tzHour * 3600 * 1000 + tzMinute * 60 * 1000) * tzSign;  
    binValue.setTimeZone(new SimpleTimeZone(offset, ""));

    if (input.hasNext())
    {
      throw new XMPException(
        "Invalid date string, extra chars at end", XMPError.BADVALUE);
    }
   
    return binValue;
  }
View Full Code Here

Examples of com.itextpdf.xmp.XMPException

   */
  private static void verifySimpleXMLName(String name) throws XMPException
  {
    if (!Utils.isXMLName(name))
    {
      throw new XMPException("Bad XML name", XMPError.BADXPATH);
    }
  }
View Full Code Here

Examples of com.itextpdf.xmp.XMPException

    // Do some basic checks on the URI and name. Try to lookup the URI. See if the name is
    // qualified.

    if (schemaNS == null || schemaNS.length() == 0)
    {
      throw new XMPException(
        "Schema namespace URI is required", XMPError.BADSCHEMA);
    }

    if ((rootProp.charAt(0) == '?') || (rootProp.charAt(0) == '@'))
    {
      throw new XMPException("Top level name must not be a qualifier", XMPError.BADXPATH);
    }

    if (rootProp.indexOf('/') >= 0 || rootProp.indexOf('[') >= 0)
    {
      throw new XMPException("Top level name must be simple", XMPError.BADXPATH);
    }

    String prefix = XMPMetaFactory.getSchemaRegistry().getNamespacePrefix(schemaNS);
    if (prefix == null)
    {
      throw new XMPException("Unregistered schema namespace URI", XMPError.BADSCHEMA);
    }

    // Verify the various URI and prefix combinations. Initialize the
    // expanded XMPPath.
    int colonPos = rootProp.indexOf(':');
    if (colonPos < 0)
    {
      // The propName is unqualified, use the schemaURI and associated
      // prefix.
      verifySimpleXMLName(rootProp); // Verify the part before any colon
      return prefix + rootProp;
    }
    else
    {
      // The propName is qualified. Make sure the prefix is legit. Use the associated URI and
      // qualified name.

      // Verify the part before any colon
      verifySimpleXMLName(rootProp.substring(0, colonPos));
      verifySimpleXMLName(rootProp.substring(colonPos));
     
      prefix = rootProp.substring(0, colonPos + 1);

      String regPrefix = XMPMetaFactory.getSchemaRegistry().getNamespacePrefix(schemaNS);
      if (regPrefix == null)
      {
        throw new XMPException("Unknown schema namespace prefix", XMPError.BADSCHEMA);
      }
      if (!prefix.equals(regPrefix))
      {
        throw new XMPException("Schema namespace URI and prefix mismatch",
            XMPError.BADSCHEMA);
      }

      return rootProp;
    }
View Full Code Here

Examples of com.itextpdf.xmp.XMPException

        return value;
     
    }
    else
    {
      throw new XMPException(errorMsg, XMPError.BADVALUE);
    }
  }
View Full Code Here

Examples of com.itextpdf.xmp.XMPException

  private void assertChildNotExisting(String childName) throws XMPException
  {
    if (!XMPConst.ARRAY_ITEM_NAME.equals(childName&&
      findChildByName(childName) != null)
    {
      throw new XMPException("Duplicate property or field node '" + childName + "'",
          XMPError.BADXMP);
    }
  }
View Full Code Here

Examples of com.itextpdf.xmp.XMPException

  private void assertQualifierNotExisting(String qualifierName) throws XMPException
  {
    if (!XMPConst.ARRAY_ITEM_NAME.equals(qualifierName&&
      findQualifierByName(qualifierName) != null)
    {
      throw new XMPException("Duplicate '" + qualifierName + "' qualifier", XMPError.BADXMP);
    }
  }
View Full Code Here

Examples of com.itextpdf.xmp.XMPException

    }
   
    if (!Utils.isXMLNameNS(suggestedPrefix.substring(0,
        suggestedPrefix.length() - 1)))
    {
      throw new XMPException("The prefix is a bad XML name", XMPError.BADXML);
    }
   
    String registeredPrefix = (String) namespaceToPrefixMap.get(namespaceURI);
    String registeredNS = (String) prefixToNamespaceMap.get(suggestedPrefix);
    if (registeredPrefix != null)
View Full Code Here

Examples of com.itextpdf.xmp.XMPException

        aliasForm.toPropertyOptions(), null).getOptions()) :
      new AliasOptions();
 
    if (p.matcher(aliasProp).find()  ||  p.matcher(actualProp).find())
    {
      throw new XMPException("Alias and actual property names must be simple",
          XMPError.BADXPATH);
    }
   
    // check if both namespaces are registered
    final String aliasPrefix = getNamespacePrefix(aliasNS);
    final String actualPrefix = getNamespacePrefix(actualNS);
    if (aliasPrefix == null)
    {
      throw new XMPException("Alias namespace is not registered", XMPError.BADSCHEMA);
    }
    else if (actualPrefix == null)
    {
      throw new XMPException("Actual namespace is not registered",
        XMPError.BADSCHEMA);
    }
   
    String key = aliasPrefix + aliasProp;
   
    // check if alias is already existing
    if (aliasMap.containsKey(key))
    {
      throw new XMPException("Alias is already existing", XMPError.BADPARAM);
    }
    else if (aliasMap.containsKey(actualPrefix + actualProp))
    { 
      throw new XMPException(
          "Actual property is already an alias, use the base property",
          XMPError.BADPARAM);
    }
   
    XMPAliasInfo aliasInfo = new XMPAliasInfo()
View Full Code Here

Examples of com.itextpdf.xmp.XMPException

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

Examples of com.itextpdf.xmp.XMPException

  {
    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
TOP
Copyright © 2018 www.massapi.com. 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.