Package lupos.datastructures.items.literal

Examples of lupos.datastructures.items.literal.Literal


      for (final Bindings b : entry.getValue()) {
        final Vector<String> columns = new Vector<String>();
        columns.add(number + ".");
        columns.add(entry.getKey());
        for (final Variable v : allVariables) {
          final Literal value = b.get(v);
          if (value == null) {
            columns.add("");
          } else {
            columns.add(value.toString(this
                .getOperatorGraphViewer().getOperatorGraph()
                .getPrefix()));
          }
        }
        data.add(columns);
View Full Code Here


          // result order is defined...
          if (resultOrder != null && resultOrder.size() > 0) {
            for (final String s : resultOrder) {
              if (variables.contains(new Variable(s))) {
                final Literal literal = ba.get(new Variable(s));
                String value = "";

                if (literal != null) {
                  value = literal.toString(prefixInstance);
                }

                if (operatorGraph == null) {
                  final LuposDocument document = new LuposDocument();
                  final LuposJTextPane textPane = new LuposJTextPane(document);
                  document.init(TurtleParser.createILuposParser(new LuposDocumentReader(document)), false);
                  textPane.setText(value);
                  textPane.setEditable(false);

                  row[j++] = textPane;
                } else {
                  row[j++] = value;
                }
              }
            }
          } else { // result order is not defined...
            for (final Variable variable : variables) {
              final Literal literal = ba.get(variable);
              String value = "";

              if (literal != null) {
                value = literal.toString(prefixInstance);
              }

              if (operatorGraph == null) {
                final LuposDocument document = new LuposDocument();
                final LuposJTextPane textPane = new LuposJTextPane(document);
View Full Code Here

      throw new RIFException("All Variables in Assignment " + toString()
          + " are unbound!");
    if (rightAssign ^ leftAssign) {
      // Einzelne ungebundene variable auf einer seite, dann einfach die
      // andere auswerten und ergebniss reinschreiben
      Literal assignValue = (Literal) (leftAssign ? rightExpr
          .evaluate(binding) : leftExpr.evaluate(binding));
      RuleVariable var = (RuleVariable) (leftAssign ? leftExpr
          : rightExpr);
      binding.add(var.getVariable(), assignValue);
      return BooleanLiteral.TRUE;
View Full Code Here

      Long id = 0l;

      //check how many entries  are in the first result of the xpathQuery and
      //go through each result
      for (int k = 0; k < queryList.get(0).getLength(); k++) {
        Literal subject = LiteralFactory.createAnonymousLiteral("<" + id + ">");
        Triple typeTriple = new Triple(subject, Literals.RDF.TYPE, this.TYPE)
        res.add(typeTriple);

        //check how many XPath expressions were submitted and go trough each result
        //add all entries to the res = (intermediate) result
        for (int i = 0; i < queryList.size(); i++) {
          //get data out of the XPath result node list
          String data = queryList.get(i).item(k).getTextContent().trim();

          // evaluate regex for information selection
          boolean addValues=true;
          // if regex given
          if (this.regexString.get(i).length()>0) {
            final Pattern pattern = Pattern.compile(this.regexString.get(i));
            final Matcher matcher = pattern.matcher(data);
            // if regex valid, extract information
            if (matcher.find() == true) {

              //the last regex value in parentheses is chosen as group             
              if(matcher.groupCount()!=0){
                data = matcher.group(matcher.groupCount());
              } else { // otherwise group 0 is chosen as complete expression
                data = matcher.group(0);             
                String buffer = data;
                data="";

                // the whole result string is checked for digits which will remain in result
                // others symbols are removed
                for(int j=0;j<buffer.length();j++){
                  Character c= buffer.charAt(j);
                  if(Character.isDigit(c)){
                    data=data+c;
                  }
                }
              }

            } else { // if regex invalid ignore data             
              addValues = false;
           
          }
          // create triple out of selected data
          if (addValues){
            System.out.println(data);
            Literal obj = Literals.createTyped(data, this.dataString.get(i));
            Triple genTriple = new Triple(subject, this.literalList.get(i), obj);
            res.add(genTriple);
          }       
        }
        //increase counter for individual subject generation
View Full Code Here

  public Object visit(final RIFRDFLiteral n, final IRuleNode argu) {
    return n.f0.accept(this, argu);
  }

  public Object visit(final RIFTypedLiteral n, final IRuleNode argu) {
    final Literal content = ((Constant) n.f0.accept(this, argu))
        .getLiteral();
    final Literal type = ((Constant) n.f2.accept(this, argu)).getLiteral();
    Literal literal;
    try {
      literal = LiteralFactory.createTypedLiteralWithoutLazyLiteral(content.toString(),
          type.toString());
    } catch (final URISyntaxException e) {
      throw new RIFException(e.getMessage());
View Full Code Here

  public Object visit(final RIFLiteralWithLangTag n, final IRuleNode argu) {
    final TypedLiteral content = (TypedLiteral) ((Constant) n.f0.accept(
        this, argu)).getLiteral();
    final String langTag = (String) n.f1.accept(this, argu);
    final Literal literal = LiteralFactory.createLanguageTaggedLiteralWithoutLazyLiteral(
        content.getContent(), langTag);
    return new Constant(literal, argu);
  }
View Full Code Here

//      literal = LiteralFactory.createTypedLiteralWithoutLazyLiteral(content,
//          "<http://www.w3.org/2001/XMLSchema#string>");
//    } catch (final URISyntaxException e) {
//      throw new RIFException(e.getMessage());
//    }
    Literal literal = LiteralFactory.createLiteral(content);
    return new Constant(literal, argu);
  }
View Full Code Here

    return n.f0.accept(this, argu);
  }

  public Object visit(final RIFQName n, final IRuleNode argu) {
    final String content = (String) n.f0.accept(this, argu);
    Literal literal = null;
    final String[] parts = content.split(":");
    if (parts[0].equals("")) {
      if (baseNamespace == null)
        throw new RIFException("Literal " + content
            + " requires Declaration of BASE!");
View Full Code Here

    return new Constant(literal, argu);
  }

  public Object visit(final RIFInteger n, final IRuleNode argu) {
    final String content = (String) n.f0.accept(this, argu);
    Literal literal;
    try {
      literal = LiteralFactory.createTypedLiteralWithoutLazyLiteral("\"" + content + "\"",
          "<http://www.w3.org/2001/XMLSchema#integer>");
    } catch (final URISyntaxException e) {
      throw new RIFException(e.toString());
View Full Code Here

    return new Constant(literal, argu);
  }

  public Object visit(final RIFFloatingPoint n, final IRuleNode argu) {
    final String content = (String) n.f0.accept(this, argu);
    Literal literal = null;
    if (content.contains("e") || content.contains("E"))
      try {
        literal = LiteralFactory.createTypedLiteralWithoutLazyLiteral("\"" + content
            + "\"", "<http://www.w3.org/2001/XMLSchema#double>");
      } catch (final URISyntaxException e) {
View Full Code Here

TOP

Related Classes of lupos.datastructures.items.literal.Literal

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.