Package org.openrdf.model

Examples of org.openrdf.model.Literal


    StringBuilder sb = new StringBuilder(66000);
    for (int i = 0; i < 66000; i++) {
      sb.append('a');
    }

    Literal longLiteral = store.getLiteralFactory().createLiteral(sb.toString());

    SailConnection con = store.getConnection();
    con.addStatement(foo, RDF.TYPE, longLiteral);
    con.close();
    store.shutDown();
View Full Code Here


    }
    else if (TransactionXMLConstants.LITERAL_TAG.equals(tagName)) {
      String lang = atts.get(TransactionXMLConstants.LANG_ATT);
      String datatype = atts.get(TransactionXMLConstants.DATATYPE_ATT);

      Literal lit;
      if (lang != null) {
        lit = valueFactory.createLiteral(text, lang);
      }
      else if (datatype != null) {
        URI dtURI = valueFactory.createURI(datatype);
View Full Code Here

    if (this == o) {
      return true;
    }

    if (o instanceof Literal) {
      Literal other = (Literal)o;

      // Compare labels
      if (!label.equals(other.getLabel())) {
        return false;
      }

      // Compare datatypes
      if (datatype == null) {
        if (other.getDatatype() != null) {
          return false;
        }
      }
      else {
        if (!datatype.equals(other.getDatatype())) {
          return false;
        }
      }

      // Compare language tags
      if (language == null) {
        if (other.getLanguage() != null) {
          return false;
        }
      }
      else {
        if (!language.equals(other.getLanguage())) {
          return false;
        }
      }

      return true;
View Full Code Here

  static class ValueComparator implements Comparator<Value> {

    public int compare(Value o1, Value o2) {
      if (o1 instanceof Literal) {
        if (o2 instanceof Literal) {
          Literal l1 = (Literal)o1;
          Literal l2 = (Literal)o2;
          if (l1.getLanguage() != null && l2.getLanguage() != null) {
            int l = l1.getLanguage().compareTo(l2.getLanguage());
            return l != 0 ? l : o1.stringValue().compareTo(o2.stringValue());
          }
          else if (l1.getLanguage() != null) {
            return -1;
          }
          else if (l2.getLanguage() != null) {
            return 1;
          }
          if (l1.getDatatype() != null && l2.getDatatype() != null) {
            int d = l1.getDatatype().stringValue().compareTo(l2.getDatatype().stringValue());
            return d != 0 ? d : o1.stringValue().compareTo(o2.stringValue());
          }
          else if (l1.getDatatype() != null) {
            return -1;
          }
          else if (l2.getDatatype() != null) {
            return 1;
          }
        }
      }
      return o1.stringValue().compareTo(o2.stringValue());
View Full Code Here

  public void testYearMonth()
    throws Exception
  {
    ValueFactory vf = new ValueFactoryImpl();
    Literal lit = vf.createLiteral("P1Y", DURATION_YEARMONTH);
    Duration duration = lit.durationValue();
    assertEquals(lit, vf.createLiteral(duration));
  }
View Full Code Here

  public void testDayTime()
    throws Exception
  {
    ValueFactory vf = new ValueFactoryImpl();
    Literal lit = vf.createLiteral("P1D", DURATION_DAYTIME);
    Duration duration = lit.durationValue();
    assertEquals(lit, vf.createLiteral(duration));
  }
View Full Code Here

  public void testFullDuration()
    throws Exception
  {
    ValueFactory vf = new ValueFactoryImpl();
    Literal lit = vf.createLiteral("P1Y1M1D", DURATION);
    Duration duration = lit.durationValue();
    assertEquals(lit, vf.createLiteral(duration));
  }
View Full Code Here

  public void parse(Model model, Resource implNode)
    throws StoreConfigException
  {
    try {
      Literal typeLit = model.filter(implNode, SAILTYPE, null).objectLiteral();
      if (typeLit != null) {
        setType(typeLit.getLabel());
      }
    }
    catch (ModelException e) {
      throw new StoreConfigException(e.getMessage(), e);
    }
View Full Code Here

  public static SailImplConfig parseRepositoryImpl(Model model, Resource implNode)
    throws StoreConfigException
  {
    try {
      Literal typeLit = model.filter(implNode, SailConfigSchema.SAILTYPE, null).objectLiteral();

      if (typeLit != null) {
        SailFactory factory = SailRegistry.getInstance().get(typeLit.getLabel());

        if (factory != null) {
          SailImplConfig implConfig = factory.getConfig();
          implConfig.parse(model, implNode);
          return implConfig;
        }
        else {
          throw new StoreConfigException("Unsupported Sail type: " + typeLit.getLabel());
        }
      }

      return null;
    }
View Full Code Here

  {
    try {
      Resource sailImplNode = model.filter(repImplNode, SAILIMPL, null).objectResource();

      if (sailImplNode != null) {
        Literal typeLit = model.filter(sailImplNode, SAILTYPE, null).objectLiteral();

        if (typeLit != null) {
          SailFactory factory = SailRegistry.getInstance().get(typeLit.getLabel());

          if (factory == null) {
            throw new StoreConfigException("Unsupported Sail type: " + typeLit.getLabel());
          }

          sailImplConfig = factory.getConfig();
          sailImplConfig.parse(model, sailImplNode);
        }
View Full Code Here

TOP

Related Classes of org.openrdf.model.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.