Package org.exist.xquery.value

Examples of org.exist.xquery.value.ValueSequence


         * TODO: Maybe we could provide more detailed messages in the trap, e.g. couldnt delete node `xyz` into `abc` becuase... this would be nicer for the end user of the xquery application
         */
        if (!Type.subTypeOf(inSeq.getItemType(), Type.NODE))
        {
          //Indicate the failure to perform this update by adding it to the sequence in the context variable XQueryContext.XQUERY_CONTEXTVAR_XQUERY_UPDATE_ERROR
          ValueSequence prevUpdateErrors = null;
         
          final XPathException xpe = new XPathException(this, Messages.getMessage(Error.UPDATE_SELECT_TYPE));
          final Object ctxVarObj = context.getXQueryContextVar(XQueryContext.XQUERY_CONTEXTVAR_XQUERY_UPDATE_ERROR);
          if(ctxVarObj == null)
          {
            prevUpdateErrors = new ValueSequence();
          }
          else
          {
            prevUpdateErrors = (ValueSequence)XPathUtil.javaObjectToXPath(ctxVarObj, context);
          }
          prevUpdateErrors.add(new StringValue(xpe.getMessage()));
      context.setXQueryContextVar(XQueryContext.XQUERY_CONTEXTVAR_XQUERY_UPDATE_ERROR, prevUpdateErrors);
     
          if(!inSeq.isEmpty())
            {throw xpe;//TODO: should we trap this instead of throwing an exception - deliriumsky?
        }
View Full Code Here



    @Override
    public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {

        final Sequence result = new ValueSequence();

        // Check input parameters
        if (args.length == 0) {
            final String uuid = UUIDGenerator.getUUIDversion4();
            result.add(new StringValue(uuid));

        } else if (args.length == 1) {
            final String parameter = args[0].getStringValue();
            final String uuid = UUIDGenerator.getUUIDversion3(parameter);
            result.add(new StringValue(uuid));

        } else {
            logger.error("Not a supported number of parameters");
            throw new XPathException("Not a supported number of parameters");
        }
View Full Code Here

  /* (non-Javadoc)
   * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence)
   */
  public Sequence eval(Sequence[] args, Sequence contextSequence)
      throws XPathException {
    final ValueSequence result = new ValueSequence();
    final Locale[] locales = Collator.getAvailableLocales();
    String locale;
    for(int i = 0; i < locales.length; i++) {
      locale = locales[i].getLanguage();
      if(locales[i].getCountry().length() > 0)
        {locale += '-' + locales[i].getCountry();}
      result.add(new StringValue(locale));
    }
    return result;
  }
View Full Code Here

       
        return result;
    }

    private Sequence copyListToValueSequence(List<String> collectionNames) {
        final ValueSequence seq = new ValueSequence(collectionNames.size());
       
        for(final String collectionName : collectionNames) {
            seq.add(new StringValue(collectionName));
        }
       
        return seq;
    }
View Full Code Here

         * TODO: Maybe we could provide more detailed messages in the trap, e.g. couldnt update node `xyz` into `abc` becuase... this would be nicer for the end user of the xquery application
         */
        if (!Type.subTypeOf(inSeq.getItemType(), Type.NODE))
        {
          //Indicate the failure to perform this update by adding it to the sequence in the context variable XQueryContext.XQUERY_CONTEXTVAR_XQUERY_UPDATE_ERROR
          ValueSequence prevUpdateErrors = null;
         
          final XPathException xpe = new XPathException(this, Messages.getMessage(Error.UPDATE_SELECT_TYPE));
          final Object ctxVarObj = context.getXQueryContextVar(XQueryContext.XQUERY_CONTEXTVAR_XQUERY_UPDATE_ERROR);
          if(ctxVarObj == null)
          {
            prevUpdateErrors = new ValueSequence();
          }
          else
          {
            prevUpdateErrors = (ValueSequence)XPathUtil.javaObjectToXPath(ctxVarObj, context);
          }
          prevUpdateErrors.add(new StringValue(xpe.getMessage()));
      context.setXQueryContextVar(XQueryContext.XQUERY_CONTEXTVAR_XQUERY_UPDATE_ERROR, prevUpdateErrors);
     
          if(!inSeq.isEmpty())
            {throw xpe;//TODO: should we trap this instead of throwing an exception - deliriumsky?
        }
View Full Code Here

      final RequestWrapper request = (RequestWrapper)value.getObject();
      final List<String> fnames = request.getUploadedFileName(uploadParamName);
      if(fnames == null) {
        return Sequence.EMPTY_SEQUENCE;
      }
      final ValueSequence result = new ValueSequence();
      for (final String name: fnames) {
        result.add(new StringValue(name));
      }
      return result;
    } else
      {throw new XPathException(this, "Variable $request is not bound to a Request object.");}
  }
View Full Code Here

                if (var.getValue().getItemType() != Type.JAVA_OBJECT)
                        {throw new XPathException(this, "Variable $request is not bound to an Java object.");}
                final JavaObjectValue value = (JavaObjectValue) var.getValue().itemAt(0);
                if (value.getObject() instanceof RequestWrapper)
                {
                        final ValueSequence result = new ValueSequence();
                        for (final Enumeration<String> e = ((RequestWrapper) value.getObject()).getHeaderNames(); e.hasMoreElements();)
                        {
                                final String param = e.nextElement();
                                result.add(new StringValue(param));
                        }
                        return result;
                }
                else
                  {throw new XPathException(this, "Variable $request is not bound to a Request object.");}
View Full Code Here

 
  //TODO: decode names?
  public Sequence evalWithCollection(Collection collection, Sequence[] args, Sequence contextSequence)
    throws XPathException {
   
    final ValueSequence result = new ValueSequence();
    try {
      final String[] collections = collection.listChildCollections();
      for(int i = 0; i < collections.length; i++) {
        result.add(new StringValue(collections[i]));
      }
      return result;
    } catch (final XMLDBException e) {
      throw new XPathException(this, "Failed to retrieve child collections", e);
    }
View Full Code Here

      final Cookie[] cookies = ((RequestWrapper)value.getObject()).getCookies();
      if(cookies != null)
      {
        if(cookies.length != 0)
        {
          final ValueSequence names = new ValueSequence();
       
          for(int c = 0; c < cookies.length; c++)
          {
            names.add(new StringValue(cookies[c].getName()));
          }
         
          return names;
        }
      }
View Full Code Here

       
        return result;
    }

    private Sequence getAllAccountMetadataKeys() throws XPathException {
        final ValueSequence result = new ValueSequence();
        for(final AXSchemaType axSchemaType : AXSchemaType.values()) {
            result.add(new AnyURIValue(axSchemaType.getNamespace()));
        }
        for(final EXistSchemaType exSchemaType : EXistSchemaType.values()) {
            result.add(new AnyURIValue(exSchemaType.getNamespace()));
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of org.exist.xquery.value.ValueSequence

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.