Examples of XMPException


Examples of com.itextpdf.xmp.XMPException

    {
      segment = segment.substring(1, segment.length() - 1);
      index = Integer.parseInt(segment);
      if (index < 1)
      {
        throw new XMPException("Array index must be larger than zero",
            XMPError.BADXPATH);
      }
    }
    catch (NumberFormatException e)
    {
      throw new XMPException("Array index not digits.", XMPError.BADXPATH);
    }
 
    if (createNodes  &&  index == arrayNode.getChildrenLength() + 1)
    {
      // Append a new last + 1 node.
View Full Code Here

Examples of com.itextpdf.xmp.XMPException

    {
      XMPNode currItem = arrayNode.getChild(index);
 
      if (!currItem.getOptions().isStruct())
      {
        throw new XMPException("Field selector must be used on array of struct",
            XMPError.BADXPATH);
      }
 
      for (int f = 1; f <= currItem.getChildrenLength(); f++)
      {
View Full Code Here

Examples of com.itextpdf.xmp.XMPException

  {
    // See if the array has the right form. Allow empty alt arrays,
    // that is what parsing returns.
    if (!arrayNode.getOptions().isArrayAltText())
    {
      throw new XMPException("Localized text array is not alt-text", XMPError.BADXPATH);
    }
    else if (!arrayNode.hasChildren())
    {
      return new Object[] { new Integer(XMPNodeUtils.CLT_NO_VALUES), null };
    }
 
    int foundGenericMatches = 0;
    XMPNode resultNode = null;
    XMPNode xDefault = null;
 
    // Look for the first partial match with the generic language.
    for (Iterator it = arrayNode.iterateChildren(); it.hasNext();)
    {
      XMPNode currItem = (XMPNode) it.next();
 
      // perform some checks on the current item
      if (currItem.getOptions().isCompositeProperty())
      {
        throw new XMPException("Alt-text array item is not simple", XMPError.BADXPATH);
      }
      else if (!currItem.hasQualifier()
          || !XML_LANG.equals(currItem.getQualifier(1).getName()))
      {
        throw new XMPException("Alt-text array item has no language qualifier",
            XMPError.BADXPATH);
      }
 
      String currLang = currItem.getQualifier(1).getValue();
 
View Full Code Here

Examples of com.itextpdf.xmp.XMPException

   */
  static int lookupLanguageItem(XMPNode arrayNode, String language) throws XMPException
  {
    if (!arrayNode.getOptions().isArray())
    {
      throw new XMPException("Language item must be used on array", XMPError.BADXPATH);
    }
 
    for (int index = 1; index <= arrayNode.getChildrenLength(); index++)
    {
      XMPNode child = arrayNode.getChild(index);
View Full Code Here

Examples of com.itextpdf.xmp.XMPException

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

Examples of com.itextpdf.xmp.XMPException

      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

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

Examples of com.itextpdf.xmp.XMPException

        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

Examples of com.itextpdf.xmp.XMPException

      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

Examples of com.itextpdf.xmp.XMPException

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