Package lupos.datastructures.items

Examples of lupos.datastructures.items.Triple


    final Class type2 = Registration.deserializeId(in)[0];
    final Object key, value;
    try {
      if (type1 == String.class && (type2 == Triple.class)) {
        value = Registration.deserializeWithoutId(type2, in);
        final Triple t = (Triple) value;
        final int compressed = in.read();
        switch (compressed) {
        case 1:
          key = new String(t.getSubject().toString() + t.getPredicate().toString() + t.getObject().toString());
          break;
        case 2:
          key = new String(t.getSubject().toString() + t.getObject().toString() + t.getPredicate().toString());
          break;
        case 3:
          key = new String(t.getPredicate().toString() + t.getSubject().toString() + t.getObject().toString());
          break;
        case 4:
          key = new String(t.getPredicate().toString() + t.getObject().toString() + t.getSubject().toString());
          break;
        case 5:
          key = new String(t.getObject().toString() + t.getSubject().toString() + t.getPredicate().toString());
          break;
        case 6:
          key = new String(t.getObject().toString() + t.getPredicate().toString() + t.getSubject().toString());
          break;
        default:
          key = Registration.deserializeWithoutId(type1, in);
        }
      } else {
View Full Code Here


    final Class type2 = Registration.deserializeId(in)[0];
    final Object key, value;
    try {
      if (type1 == String.class && (type2 == Triple.class)) {
        value = Registration.deserializeWithoutId(type2, in);
        final Triple t = (Triple) value;
        final int compressed = in.read();
        switch (compressed) {
        case 1:
          key = new String(t.getSubject().toString() + t.getPredicate().toString() + t.getObject().toString());
          break;
        case 2:
          key = new String(t.getSubject().toString() + t.getObject().toString() + t.getPredicate().toString());
          break;
        case 3:
          key = new String(t.getPredicate().toString() + t.getSubject().toString() + t.getObject().toString());
          break;
        case 4:
          key = new String(t.getPredicate().toString() + t.getObject().toString() + t.getSubject().toString());
          break;
        case 5:
          key = new String(t.getObject().toString() + t.getSubject().toString() + t.getPredicate().toString());
          break;
        case 6:
          key = new String(t.getObject().toString() + t.getPredicate().toString() + t.getSubject().toString());
          break;
        default:
          key = Registration.deserializeWithoutId(type1, in);
        }
      } else {
View Full Code Here

            final Iterator<Triple> it1 = arg1.getTriples()
                .iterator();
            while (it0.hasNext()) {
              if (!it1.hasNext())
                return -1;
              final Triple t0 = it0.next();
              final Triple t1 = it1.next();
              final int compare = tc.compare(t0, t1);
              if (compare != 0)
                return compare;
            }
            if (it1.hasNext())
View Full Code Here

    /**
     * generate Triple List to return
     */

    if (this.thumbnail != null) {
      t.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS,
          Predicates.THUMBNAIL, this.thumbnail));
    }
    if (this.wikiarticle != null) {
      t.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS,
          Predicates.WIKIARTICLE, this.wikiarticle));
    }
    if (this.subject != null) {
      t.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS,
          Predicates.SUBJECT, this.subject));
    }
    if (this.name != null) {
      t.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS,
          Predicates.NAME, this.name));
    }
    if (this.birthDate != null) {
      t.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS,
          Predicates.BIRTHDATE, this.birthDate));
    }
    if (this.deathDate != null) {
      t.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS,
          Predicates.DEATHDATE, this.deathDate));
    }

    if (this.label != null) {
      t.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS,
          Predicates.LABEL, this.label));
    }
    if (this.comment != null) {
      t.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS,
          Predicates.COMMENT, this.comment));
    }
    if (this.birthPlace != null) {
      t.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS,
          Predicates.BIRTHPLACE, this.birthPlace));
    }
    return t;
  }
View Full Code Here

    messageLinkObject = Literals.createTyped(new URL(this.getLink())+"", Literals.XSD.ANYURI);
    messageAuthorObject = Literals.createTyped(this.getAuthor()+"", Literals.XSD.String);
    messageGuidObject = Literals.createTyped(this.getGuid()+"", Literals.XSD.ANYURI);
   
    //generate triples
    Triple messageTypeTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Literals.RDF.TYPE, FeedMessage.TYPE);
    Triple messageTitleTriple = new Triple();
    Triple messageDescriptionTriple = new Triple();
    Triple messageLinkTriple = new Triple();
    Triple messageAuthorTriple = new Triple();
    Triple messageGuidTriple = new Triple();
   
    if(messageTitleObject != Literals.createTyped("",Literals.XSD.String)){
      messageTitleTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.TITLE, messageTitleObject);
    }
    if(messageDescriptionObject != Literals.createTyped("",Literals.XSD.String)){
      messageDescriptionTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.DESCRIPTION, messageDescriptionObject);
    }
    if(messageLinkObject != Literals.createTyped("",Literals.XSD.String)){
      messageLinkTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.LINK, messageLinkObject);
    }
    if(messageAuthorObject != Literals.createTyped("",Literals.XSD.String)){
      messageAuthorTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.AUTHOR, messageAuthorObject);
    }
    if(messageGuidObject != Literals.createTyped("",Literals.XSD.String)){
      messageGuidTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.GUID, messageGuidObject);
    }
   
    // generate Triple List to return
    ArrayList<Triple> t = new ArrayList<Triple>();
    t.add(messageTypeTriple);
View Full Code Here

      // for each station, compose a new event
      for (StationDelayInfo sdi : train.delayPerStation) {
        List<Triple> event = stationDelayInfoToTriples(subj, sdi);

        // add the event type and the train's name
        event.add(0, new Triple(subj, Literals.RDF.TYPE, TYPE));
        event.add(1, new Triple(subj, TRAIN_NAME, nameObj));

        result.add(event);
      }
    } catch (Exception e) {
      System.err.println(e);
View Full Code Here

    try {
      Literal obj;

      // station name
      obj = LiteralFactory.createTypedLiteral("\"" + sdi.station.name + "\"", Literals.XSD.String);
      result.add(new Triple(trainSubj, STATION_NAME, obj));

      // latitude, longitude
      obj = Literals.createTyped(sdi.station.latitude + "", Literals.XSD.FLOAT);
      result.add(new Triple(trainSubj, LATITUDE, obj));

      obj = Literals.createTyped(sdi.station.longitude + "", Literals.XSD.FLOAT);
      result.add(new Triple(trainSubj, LONGITUDE, obj));

      // delay

      // split delay into days, hours, minutes
      int totalMinutes = sdi.delayMinutes;

      int days = totalMinutes / 1440;
      totalMinutes -= days * 1440;

      int hours = totalMinutes / 60;
      totalMinutes -= hours * 60;

      int minutes = totalMinutes;

      obj = Literals.createDurationLiteral(0, 0, days, hours, minutes, 0);
      result.add(new Triple(trainSubj, DELAY, obj));

      // delay cause
      obj = LiteralFactory.createTypedLiteral("\"" + sdi.delayCause + "\"", Literals.XSD.String);
      result.add(new Triple(trainSubj, DELAY_CAUSE, obj));
    } catch (URISyntaxException e) {
      System.err.println(e);
      e.printStackTrace();
    }

View Full Code Here

        final Literal longi2Object = Literals.createTyped(longi2Value, Literals.XSD.DECIMAL);
        final Literal elev2Object = Literals.createTyped(elev2Value, Literals.XSD.DECIMAL);
       
       
        // Adds triples (subject, predicate, object) to the array list
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Literals.RDF.TYPE, Predicates.TYPE));
       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.CURRENT_CITY, currentCityObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.COUNTRY2CODE, country2CodeObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.LATITUDE2, lati2Object));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.LONGITUDE2, longi2Object));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.ELEVATION2, elev2Object));
       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.CITY_NAME, cityNameObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.COUNTRY_NAME, countryNameObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.COUNTRYCODE, countryCodeObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.LATITUDE, latiObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.LONGITUDE, longiObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.ELEVATION, elevObject));
         
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.CURRENT_TIME, currentTimeObject))
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.OBSERVATION_TIME, observationTimeObject))
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.ZT_SHORT, ztShortObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.ZT_LONG, ztLongObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.CURRENT_WEATHER, currentWeatherObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.TEMPERATURE, temperatureObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.FEELSLIKE, feelslikeObject));
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.HUMIDITY, humidityObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.WIND, windObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.WIND_DEGREE, windDegreeObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.WIND_KPH, windKPHObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.WIND_GUST_KPH, windGustKPHObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.PRESSURE_MB, pressureMBObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.PRESSURE_IN, pressureINObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.DEWPOINT, dewpointObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.HEAT_INDEX, heatIndexObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.WINDCHILL, windchillObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.VISIBILITY_MI, visibilityMIObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.VISIBILITY_KM, visibilityKMObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.SOLARRADIATION, solarRadiationObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.UV, uvObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.PRECIP_1HR, precip1hrObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.PRECIP_TODAY, precipTodayObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.ICON, iconObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.ICON_URL, iconUrlObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.FORECAST_URL, forecastUrlObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.HISTORY_URL, historyUrlObject));       
        triples.add(new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.OB_URL, obUrlObject));
       
       
        // returns the array list with all the requested information
        return ProducerBase.fold(triples);
View Full Code Here

      CpuTimes currentCpuTimes = this.monitor.cpuTimes();
      float usage = currentCpuTimes.getCpuUsage(this.previousCpuTimes);
      this.previousCpuTimes = currentCpuTimes;

      // build triples
      Triple typeTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Literals.RDF.TYPE, SysMonProducer.TYPE);
     
      Literal uptimeObj = Literals.createTyped(uptime+"", Literals.XSD.LONG);
      Triple uptimeTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.UPTIME, uptimeObj);
     
      Literal usageObj = Literals.createTyped(usage+"", Literals.XSD.FLOAT);
      Triple usageTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.CPU_USAGE, usageObj);
     
      Triple cpuFrequencyInHzTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.CPU_FREQUENCY, Literals.createTyped(cpuFrequencyInHz+"", Literals.XSD.LONG));
     
      Triple currentPIDTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.PID, Literals.createTyped(currentPID+"", Literals.XSD.INT));
      Triple numberOfCPUsTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.CPUS, Literals.createTyped(numberOfCPUs+"", Literals.XSD.INT));
      Triple osNameTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.OS, Literals.createTyped(osName+"", Literals.XSD.String));
      Triple totalPhysicalBytesTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.TOTAL_PHYSICAL_BYTES, Literals.createTyped(totalPhysicalBytes+"", Literals.XSD.LONG));
      Triple freePhysicalBytesTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.FREE_PHYSICAL_BYTES, Literals.createTyped(freePhysicalBytes+"", Literals.XSD.LONG));
      Triple totalSwapBytesTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.TOTAL_SWAP_BYTES, Literals.createTyped(totalSwapBytes+"", Literals.XSD.LONG));
      Triple freeSwapBytesTriple = new Triple(Literals.AnonymousLiteral.ANONYMOUS, Predicates.FREE_SWAP_BYTES, Literals.createTyped(freeSwapBytes+"", Literals.XSD.LONG));

      return ProducerBase.fold(Arrays.asList(typeTriple, uptimeTriple, usageTriple, cpuFrequencyInHzTriple, currentPIDTriple, numberOfCPUsTriple, osNameTriple, totalPhysicalBytesTriple, freePhysicalBytesTriple, totalSwapBytesTriple, freeSwapBytesTriple));
    } catch (URISyntaxException e) {
      System.err.println(e);
      e.printStackTrace();
View Full Code Here

       
        //Create an anonymous id
        Literal subject = LiteralFactory.createAnonymousLiteral("<"+id+">");

        //Create triples for each attribute
        triples.add(new Triple(subject, Literals.RDF.TYPE, EVENT_TYPE_OBJECT));
        triples.add(new Triple(subject, HEADLINER_PREDICATE, LiteralFactory.createStringLiteral("\""+Utils.escape(headliner)+"\"")));
        triples.add(new Triple(subject, ID_PREDICATE, LiteralFactory.createTypedLiteral("\""+id+"\"", Literals.XSD.LONG)));
        triples.add(new Triple(subject, TITLE_PREDICATE, LiteralFactory.createStringLiteral("\""+Utils.escape(title)+"\"")));
        triples.add(new Triple(subject, START_PREDICATE, LiteralFactory.createTypedLiteral("\""+date1+"\"", XSD.DATETIME)));
        triples.add(new Triple(subject, NAME_PREDICATE, LiteralFactory.createStringLiteral("\""+Utils.escape(location)+"\"")));
        triples.add(new Triple(subject, STREET_PREDICATE, LiteralFactory.createStringLiteral("\""+Utils.escape(street)+"\"")));
        triples.add(new Triple(subject, POSTALCODE_PREDICATE, LiteralFactory.createStringLiteral("\""+Utils.escape(postalcode)+"\"")));
        triples.add(new Triple(subject, CITY_PREDICATE, LiteralFactory.createStringLiteral("\""+Utils.escape(city)+"\"")));
        triples.add(new Triple(subject, DESCRIPTION_PREDICATE, LiteralFactory.createStringLiteral("\""+Utils.escape(description)+"\"")));
        triples.add(new Triple(subject, URL_PREDICATE, LiteralFactory.createTypedLiteral("\""+url+"\"", XSD.ANYURI)));
        triples.add(new Triple(subject, IMAGE_PREDICATE, LiteralFactory.createStringLiteral("\""+Utils.escape(image)+"\"")));
       
        events.add(triples);
      }     
      return events;     
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of lupos.datastructures.items.Triple

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.