Package com.adobe.xmp

Examples of com.adobe.xmp.XMPException


    }
    pos.nameEnd = pos.stepEnd;

    if (pos.stepEnd == pos.stepBegin)
    {
      throw new XMPException("Empty XMPPath segment", XMPError.BADXPATH);
    }

    // ! Touch up later, also changing '@' to '?'.
    XMPPathSegment segment = new XMPPathSegment(pos.path.substring(pos.stepBegin, pos.stepEnd),
        XMPPath.STRUCT_FIELD_STEP);
View Full Code Here


        pos.stepEnd++;
      }
     
      if (pos.stepEnd >= pos.path.length())
      {
        throw new XMPException("Missing ']' or '=' for array index", XMPError.BADXPATH);
      }

      if (pos.path.charAt(pos.stepEnd) == ']')
      {
        if (!"[last()".equals(pos.path.substring(pos.stepBegin, pos.stepEnd)))
        {
          throw new XMPException(
            "Invalid non-numeric array index", XMPError.BADXPATH);
        }
        segment = new XMPPathSegment(null, XMPPath.ARRAY_LAST_STEP);
      }
      else
      {
        pos.nameStart = pos.stepBegin + 1;
        pos.nameEnd = pos.stepEnd;
        pos.stepEnd++; // Absorb the '=', remember the quote.
        char quote = pos.path.charAt(pos.stepEnd);
        if (quote != '\'' && quote != '"')
        {
          throw new XMPException(
            "Invalid quote in array selector", XMPError.BADXPATH);
        }

        pos.stepEnd++; // Absorb the leading quote.
        while (pos.stepEnd < pos.path.length())
        {
          if (pos.path.charAt(pos.stepEnd) == quote)
          {
            // check for escaped quote
            if (pos.stepEnd + 1 >= pos.path.length()
                || pos.path.charAt(pos.stepEnd + 1) != quote)
            {
              break;
            }
            pos.stepEnd++;
          }
          pos.stepEnd++;
        }

        if (pos.stepEnd >= pos.path.length())
        {
          throw new XMPException("No terminating quote for array selector",
              XMPError.BADXPATH);
        }
        pos.stepEnd++; // Absorb the trailing quote.

        // ! Touch up later, also changing '@' to '?'.
        segment = new XMPPathSegment(null, XMPPath.FIELD_SELECTOR_STEP);
      }
    }
   

    if (pos.stepEnd >= pos.path.length() || pos.path.charAt(pos.stepEnd) != ']')
    {
      throw new XMPException("Missing ']' for array index", XMPError.BADXPATH);
    }
    pos.stepEnd++;
    segment.setName(pos.path.substring(pos.stepBegin, pos.stepEnd));
   
    return segment;
View Full Code Here

      pos.stepEnd++;
    }

    if (pos.stepEnd == pos.stepBegin)
    {
      throw new XMPException("Empty initial XMPPath step", XMPError.BADXPATH);
    }
   
    String rootProp = verifyXPathRoot(schemaNS, pos.path.substring(pos.stepBegin, pos.stepEnd));
    XMPAliasInfo aliasInfo = XMPMetaFactory.getSchemaRegistry().findAlias(rootProp);
    if (aliasInfo == null)
View Full Code Here

        if (regURI != null)
        {
          return;
        }

        throw new XMPException("Unknown namespace prefix for qualified name",
            XMPError.BADXPATH);
      }
    }
   
    throw new XMPException("Ill-formed qualified name", XMPError.BADXPATH);
  }
View Full Code Here

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

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

          prefix = XMPMetaFactory.getSchemaRegistry().registerNamespace(namespaceURI,
              suggestedPrefix);
        }
        else
        {
          throw new XMPException("Unregistered schema namespace URI",
              XMPError.BADSCHEMA);
       
      } 
       
      schemaNode.setValue(prefix);
View Full Code Here

  {
    if (!parent.getOptions().isSchemaNode() && !parent.getOptions().isStruct())
    {
      if (!parent.isImplicit())
      {
        throw new XMPException("Named children only allowed for schemas and structs",
            XMPError.BADXPATH);
     
      else if (parent.getOptions().isArray())
      {
        throw new XMPException("Named children not allowed for arrays",
            XMPError.BADXPATH);
      }
      else if (createNodes)
      { 
        parent.getOptions().setStruct(true);
View Full Code Here

    PropertyOptions leafOptions) throws XMPException
  {
    // check if xpath is set.
    if (xpath == null  ||  xpath.size() == 0)
    {
      throw new XMPException("Empty XMPPath", XMPError.BADXPATH);
    }

    // Root of implicitly created subtree to possible delete it later.
    // Valid only if leaf is new.
    XMPNode rootImplicitNode = null;
View Full Code Here

      options.setArray(true);
    }
 
    if (options.isCompositeProperty() && itemValue != null && itemValue.toString().length() > 0)
    {
      throw new XMPException("Structs and arrays can't have values",
        XMPError.BADOPTIONS);
    }
 
    options.assertConsistency(options.getOptions());
   
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.