Package lupos.datastructures.items.literal

Examples of lupos.datastructures.items.literal.Literal


        long id = jsonObj.getLong("id");

        // String from_user = jsonObj.getString("from_user");
        String text = jsonObj.getString("text");

        Literal subject = LiteralFactory.createAnonymousLiteral("<"+id+">");

        triples.add(new Triple(subject, Literals.RDF.TYPE, this.TWEET_TYPE_OBJECT));
        triples.add(new Triple(subject, this.TEXT_PREDICATE, LiteralFactory.createStringLiteral("\""+Utils.escape(text)+"\"")));
        triples.add(new Triple(subject, this.ID_PREDICATE, LiteralFactory.createTypedLiteral("\""+id+"\"", Literals.XSD.LONG)));
       
View Full Code Here


    if(Utils.isHomogenousList(msg, SerializedTriple.class)) {
      List<SerializedTriple> stl = (List<SerializedTriple>)msg;
           
      // -deserialize the triples and make subjects unique
      // -das type-Tripel wird als letztes eingespeist
      Literal subject = LiteralFactory.createAnonymousLiteral("_:broker"+this.running_number);
      this.running_number++;
      System.out.println(subject);
      Triple typeTriple = null;
      for(SerializedTriple st : stl) {
        Triple t = st.getTriple();       
View Full Code Here

    if(Utils.isHomogenousList(msg, SerializedTriple.class)) {
      List<SerializedTriple> stl = (List<SerializedTriple>)msg;
           
      // -deserialize the triples and make subjects unique
      // -das type-Tripel wird als letztes eingespeist
      Literal subject = LiteralFactory.createAnonymousLiteral("_:subj"+UUID.randomUUID());
      Triple typeTriple = null;
      for(SerializedTriple st : stl) {
        Triple t = st.getTriple();       
        Triple nt = new Triple(subject, t.getPredicate(), t.getObject());
       
View Full Code Here

    final LinkedList<Variable> replaceLitLeft = replaceLit
        .getSubstitutionsLiteralLeft();
    final LinkedList<Literal> replaceLitRight = replaceLit
        .getSubstitutionsLiteralRight();
    Variable var;
    Literal lit;
    for (int i = replaceLitLeft.size() - 1; i >= 0; i--) {
      var = replaceLitLeft.get(i);
      // Split ReplaceLit and pull only not intersection variables
      // downwards
      if (!arrayContains(joinVars, var)) {
View Full Code Here

   * @return
   */
  public Triple getTriple() {

    try {     
      Literal s = LazyLiteral.getLiteral(this.subjectStr);
      Literal p = LazyLiteral.getLiteral(this.predicateStr);
      Literal o = LazyLiteral.getLiteral(this.objectStr);
      return new Triple(s, p, o);
   
    } catch(Exception ex) {
      System.err.println(ex);
      ex.printStackTrace();
View Full Code Here

   *            TriplePattern
   * @return Whether match between parameter objects are possible
   */
  private static boolean matchPossible(final Item[] generateItems,
      final Item[] patItems, final boolean doNotConnectInferenceRules) {
    Literal patLit;
    Literal generateLit;
    for (int b = 0; b < 3; b++) {
      // If there is one Generate literal, which is not equal to
      // corresponding TriplePattern literal, then no match is possible
      if ((!generateItems[b].isVariable()) && (!patItems[b].isVariable())) {
        generateLit = (Literal) generateItems[b];
        patLit = (Literal) patItems[b];
        if (!generateLit.equals(patLit)) {
          return false;
        }
      }
      if (doNotConnectInferenceRules) {
        // check: if the triple pattern is a triple pattern of an
        // inference
        // rule,
        // then we do not connect them, as all triples based on only
        // ontology information are before inferred (when the rules for
        // the ontology are applied)!
        if (patItems[b].isVariable()
            && patItems[b] instanceof VariableInInferenceRule)
          return false;
      }
    }
    // If TriplePattern has two identical variables then generate should not
    // contain different literals at these positions
    final HashMap<Variable, Literal> varPositions = new HashMap<Variable, Literal>();
    for (int b = 0; b < 3; b++) {
      if (patItems[b].isVariable()) {
        final Variable v = (Variable) patItems[b];
        if ((varPositions.get(v) == null)
            && (!generateItems[b].isVariable())) { // new variable
          // found => store the binding for next time
          varPositions.put(v, (Literal) generateItems[b]);
        } else if ((varPositions.get(v) != null)
            && (!generateItems[b].isVariable())) {
          final Literal lit = varPositions.get(v);
          final Literal newLit = (Literal) generateItems[b];
          if (!lit.equals(newLit)) {
            return false;
          }
        }
      }
View Full Code Here

          String chosenEvent = eventCB.getSelectedItem().toString();
     
           // creates an array list
        List<Triple> triples = new ArrayList<Triple>();

        Literal type;
       
        // compare the chosenEvent with Strings of Events to know which event one wants to produce
        if (chosenEvent == "AlarmEvent") {
          type = LazyLiteral.getLiteral("<http://localhost/events/Alarm/AlarmEvent>");
        else if (chosenEvent == "CountEvent") {
          type = LazyLiteral.getLiteral("<http://localhost/events/Count/CountEvent>");
        } else if (chosenEvent == "MtGoxEvent") {
          type = LazyLiteral.getLiteral("<http://localhost/events/MtGox/MtGoxEvent>");
        } else if (chosenEvent == "SysMonEvent") {
          type = LazyLiteral.getLiteral("<http://localhost/events/SysMon/SysMonEvent>");
        } else if (chosenEvent == "TwitterSearchEvent") {
          type = LazyLiteral.getLiteral("<http://localhost/events/TwitterSearch/TwitterSearchEvent>");
        } else if (chosenEvent == "ButtonClickedEvent") {
          type = LazyLiteral.getLiteral("<http://localhost/events/ButtonClicked/ButtonClickedEvent>");
        } else if (chosenEvent == "BTDevicesEvent") {
          type = LazyLiteral.getLiteral("<http://localhost/events/BTDevices/BTDevicesEvent>");
        } else if (chosenEvent == "EbayAuctionEvent") {
          type = LazyLiteral.getLiteral("<http://localhost/events/Ebay/EbayAuctionEvent>");
        } else if (chosenEvent == "WeatherEvent") {
          type = LazyLiteral.getLiteral("<http://localhost/events/Weather/WeatherEvent>");
        } else if (chosenEvent == "MoonEvent") {
          type = LazyLiteral.getLiteral("<http://localhost/events/Moon/MoonEvent>");
        } else {
          type = LazyLiteral.getLiteral(chosenEvent);
        }
     
        // add triples of the chosen event to triples
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Literals.RDF.TYPE, type));     
     
        /**
         * Gets all components from the predicatePanel and checks the validity.
         */
        for(Component component: predicatePanel.getComponents()){
          if(component instanceof PredObjPanel){
            PredObjPanel pop = (PredObjPanel) component;
           
            Literal s = null;
            Literal k = null;

            // check if predicates in valid format
            try {
              s = this.getLiteral(pop.predTF.getText());
            } catch (ParseException e1) {
View Full Code Here

    }
  }

  public static Triple transformSesameStatementToTriple(
      final org.openrdf.model.Statement arg0) {
    Literal subj = null, pred = null, obj = null;
    final org.openrdf.model.Resource subject = arg0.getSubject();
    if (subject instanceof URI) {
      try {
        subj = LiteralFactory.createURILiteral("<"
            + ((URI) subject).getNamespace()
View Full Code Here

   */
  private List<Triple> mealinfoToTriple(MealInfo meal) {
    List<Triple> triples = new ArrayList<Triple>();

    try {
      Literal subj = LiteralFactory.createAnonymousLiteral("_:t"
          + meal.id);
      triples.add(new Triple(subj, Literals.RDF.TYPE, TYPE));

      Literal obj;
      obj = LiteralFactory.createLiteral("\"" + meal.name + "\"");
      triples.add(new Triple(subj, NAME, obj));

      obj = LiteralFactory.createLiteral("\"" + meal.price + "\"");
      triples.add(new Triple(subj, PRICE, obj));
View Full Code Here

        // creates an array list
        List<Triple> triples = new ArrayList<Triple>();
       
        // create an event instance for found weather
        // create triples
        final Literal percentIlluminatedObject = Literals.createTyped(percentIlluminatedValue, Literals.XSD.DECIMAL);
        final Literal ageOfMoonObject = Literals.createTyped(ageOfMoonValue, Literals.XSD.DECIMAL);       
        final Literal currentHourObject = Literals.createTyped(currentHourValue, Literals.XSD.DECIMAL);
        final Literal currentMinuteObject = Literals.createTyped(currentMinuteValue, Literals.XSD.DECIMAL);
        final Literal sunriseHourObject = Literals.createTyped(sunriseHourValue, Literals.XSD.DECIMAL);
        final Literal sunriseMinuteObject = Literals.createTyped(sunriseMinuteValue, Literals.XSD.DECIMAL);       
        final Literal sunsetHourObject = Literals.createTyped(sunsetHourValue, Literals.XSD.DECIMAL);
        final Literal sunsetMinuteObject = Literals.createTyped(sunsetMinuteValue, Literals.XSD.DECIMAL);
       
 
        // Adds triples (subject, predicate, object) to the array list
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Literals.RDF.TYPE, Predicates.TYPE));
       
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.