Package org.exist.xquery.value

Examples of org.exist.xquery.value.Item


  public RemoveFunction(XQueryContext context, FunctionSignature signature) {
    super(context, signature);
  }

  public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    Item item = args[0].itemAt(0);
    try {
      String key = serialize(args[1]);
      if (item.getType()==Type.STRING){
        if( logger.isDebugEnabled() ) {
          logger.debug("removing cache value [" + item.getStringValue() + ", " + key +"]");
        }
        return Cache.remove(item.getStringValue(), key);
      } else {
        if( logger.isDebugEnabled() ) {
          logger.debug("removing cache value [" + item.toJavaObject(Cache.class).toString() + ", " + key +"]");
        }
        return ((Cache)item.toJavaObject(Cache.class)).remove(key);
      }
    } catch (SAXException e) {
      logger.error("Error removing cache value", e);
    }
    return Sequence.EMPTY_SEQUENCE;
View Full Code Here


        // process
        if(args[0].isEmpty()) {
            return Sequence.EMPTY_SEQUENCE;
        }

        Item inputNode = args[0].itemAt(0);

        // get mime-type
        String mimeType = args[1].getStringValue();

        // get parameters
        Properties parameters = new Properties();
        if(!args[2].isEmpty()) {
            parameters = ModuleUtils.parseParameters(((NodeValue) args[2].itemAt(0)).getNode());
        }

        ProcessorAdapter adapter = null;
        try {
            adapter = ((XSLFOModule)getParentModule()).getProcessorAdapter();

            NodeValue configFile = args.length == 4 ? (NodeValue)args[3].itemAt(0) : null;
            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            ContentHandler contentHandler = adapter.getContentHandler(context.getBroker(), configFile, parameters, mimeType, baos);

            // process the XSL-FO
            contentHandler.startDocument();
            inputNode.toSAX(context.getBroker(), contentHandler, new Properties());
            contentHandler.endDocument();

            // return the result
            return BinaryValueFromInputStream.getInstance(context, new Base64BinaryValueType(), new ByteArrayInputStream(baos.toByteArray()));
        } catch(SAXException se) {
View Full Code Here

  public PutFunction(XQueryContext context, FunctionSignature signature) {
    super(context, signature);
  }

  public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    Item item = args[0].itemAt(0);
    Sequence value = args[2];
    try {
      String key = serialize(args[1]);
      if (item.getType()==Type.STRING){
        if( logger.isTraceEnabled() ) {
          logger.trace("putting cache value [" + item.getStringValue() + ", " + key +"]");
        }
        return Cache.put(item.getStringValue(), key, value);
      } else {
        if( logger.isTraceEnabled() ) {
          logger.trace("putting cache value [" + item.toJavaObject(Cache.class).toString() + ", " + key +"]");
        }
        return ((Cache)item.toJavaObject(Cache.class)).put(key, value);
      }
    } catch (SAXException e) {
      logger.error("Error putting cache value", e);
    }
    return Sequence.EMPTY_SEQUENCE;
View Full Code Here

    long clientHandle = ((IntegerValue) args[0].itemAt(0)).getLong();
    MemcachedClient client = MemcachedModule.retrieveClient(clientHandle);

    String key = args[1].itemAt(0).getStringValue();
   
    Item data = args[2].itemAt(0);
   
    Object o;
    if (data.getType() == Type.BASE64_BINARY){
      o = ((BinaryValue)data).toJavaObject(byte[].class);
    } else {
      o = data.getStringValue();
    }
   
    int exp = ((IntegerValue) args[3].itemAt(0)).getInt();

    if (isCalledAs("set")){
View Full Code Here

  public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    if (args.length==0){
      logger.info("Clearing all caches");
      Cache.clearGlobal();
    } else {
      Item item = args[0].itemAt(0);
      if (item.getType()==Type.STRING){
        if( logger.isDebugEnabled() ) {
          logger.debug("Clearing cache [" + item.getStringValue() + "]");
        }
        Cache.clear(item.getStringValue());
      } else {
        if( logger.isDebugEnabled() ) {
          logger.debug("Clearing cache [" + item.toJavaObject(Cache.class).toString() + "]");
        }
        ((Cache)item.toJavaObject(Cache.class)).clear();
      }
    }
    if( logger.isDebugEnabled() ) {
      logger.debug("Cache cleared");
    }
View Full Code Here

    String tmp = "";
    Serializer serializer = context.getBroker().getSerializer();
        serializer.reset();
        serializer.setProperties(OUTPUT_PROPERTIES);
        for (SequenceIterator i = q.iterate(); i.hasNext();){
          Item item = i.nextItem();
          try {
              NodeValue node = (NodeValue)item;
              tmp += serializer.serialize(node);
          } catch (ClassCastException e){
            tmp += item.getStringValue();
          }
        }
        return tmp;
  }
View Full Code Here

  public GetFunction(XQueryContext context, FunctionSignature signature) {
    super(context, signature);
  }

  public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    Item item = args[0].itemAt(0);
    try {
      String key = serialize(args[1]);
      if (item.getType()==Type.STRING){
        if( logger.isTraceEnabled() ) {
          logger.trace("getting cache value [" + item.getStringValue() + ", " + key +"]");
        }
        return Cache.get(item.getStringValue(), key);
      } else {
        if( logger.isTraceEnabled() ) {
          logger.trace("getting cache value [" + item.toJavaObject(Cache.class).toString() + ", " + key +"]");
        }
        return ((Cache)item.toJavaObject(Cache.class)).get(key);
      }
    } catch (SAXException e) {
      logger.error("Error getting cache value", e);
    }
    return Sequence.EMPTY_SEQUENCE;
View Full Code Here

              return Sequence.EMPTY_SEQUENCE;
           
            // Get first agument, these are the documents / collections to search in
            for (SequenceIterator i = pathSeq.iterate(); i.hasNext();) {
              String path;
                Item item = i.nextItem();
                if (Type.subTypeOf(item.getType(), Type.NODE)) {
                  if (((NodeValue)item).isPersistentSet()) {
                    path = ((NodeProxy)item).getDocument().getURI().toString();
                  } else {
                    path = item.getStringValue();
                  }
                } else {
                  path = item.getStringValue();
                }
                toBeMatchedURIs.add(path);
            }

            // Get second argument, this is the query
View Full Code Here

      if (sort != null)
        selected = sort.eval(selected, null);
     
//      for (Item each : selected) {
        for (SequenceIterator iterInner = selected.iterate(); iterInner.hasNext();) {
            Item each = iterInner.nextItem();  

            //Sequence seq = childNodes.eval(contextSequence, each);
        Sequence answer = super.eval(contextSequence, each);
        result.addAll(answer);
      }
View Full Code Here

          contentString = "";
            else {
                StringBuilder buf = new StringBuilder();
                for(SequenceIterator i = contentSeq.iterate(); i.hasNext(); ) {
                    context.proceed(this, builder);
                    Item next = i.nextItem();
                    if(buf.length() > 0)
                        buf.append(' ');
                    buf.append(next.getStringValue());
                }
                while (buf.length() > 0 && Character.isWhitespace(buf.charAt(0)))
                    buf.deleteCharAt(0);
                contentString = buf.toString();
            }
View Full Code Here

TOP

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

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.