Package org.ontoware.rdfreactor.runtime

Examples of org.ontoware.rdfreactor.runtime.RDFDataException


    if (node instanceof PlainLiteral) {
      return toShort(node.asLiteral());
    }

    if (node instanceof LanguageTagLiteral) {
      throw new RDFDataException(
          "Cannot convert a language tagged literal to an Short - it makes no sense");
    }

    if (node instanceof DatatypeLiteral) {
      URI datatype = node.asDatatypeLiteral().getDatatype();
      if (datatype.equals(XSD._short)) {
        return toShort(node.asDatatypeLiteral());
      } else {
        throw new RDFDataException("Cannot convert from datatype "
            + datatype + " to URI");
      }
    }

    throw new RDFDataException("Cannot convert from " + node.getClass()
        + " to Short");
  }
View Full Code Here


  public java.net.URL convert(Node node) {
    if (node == null)
      return null;

    if (node instanceof LanguageTagLiteral) {
      throw new RDFDataException(
          "Cannot convert a language tagged literal to a URI - it makes no sense");
    }

    try {
      if (node instanceof URI) {
        return new URL(node.asURI().toString());
      }

      if (node instanceof PlainLiteral) {
        return new java.net.URL(node.asLiteral().getValue());
      }

      if (node instanceof DatatypeLiteral) {
        URI datatype = node.asDatatypeLiteral().getDatatype();
        if (datatype.equals(XSD._anyURI)) {
          return new java.net.URL(node.asDatatypeLiteral().getValue());
        } else {
          throw new RDFDataException("Cannot convert from datatype "
              + datatype + " to URI");
        }
      }
    } catch (MalformedURLException e) {
      throw new RDFDataException("Could not convert <"
          + node.asLiteral().getValue() + "> to a java.net.URL", e);
    }

    throw new RDFDataException("Cannot convert from " + node.getClass()
        + " to URL");
  }
View Full Code Here

  public Node toNode(Model model, Object javaValue) {
    try {
      return model.createURI(((URL) javaValue).toURI() + "");
    } catch (URISyntaxException e) {
      throw new RDFDataException("error in URL syntax?",e);
    }
  }
View Full Code Here

      if (datatype.equals(XSD._string)
          || datatype.equals(XSD._normalizedString)) {
        return node.asDatatypeLiteral().getValue();
      } else {
        throw new RDFDataException("Cannot convert from datatype "
            + datatype + " to URI");
      }
    }

    throw new RDFDataException("Cannot convert from " + node.getClass()
        + " to Float");
  }
View Full Code Here

    if (node instanceof DatatypeLiteral) {
      DatatypeLiteral dnode = (DatatypeLiteral) node;
      if (dnode.getDatatype().equals(XSD._boolean)) {
        return new Boolean(Boolean.parseBoolean(dnode.getValue()));
      } else
        throw new RDFDataException("Datatype is " + dnode.getDatatype()
            + " which is not known");
    }

    if (node instanceof LanguageTagLiteral) {
      throw new RDFDataException(
          "Cannot convert languageTaggedLiterals to booleans - because that is more often an error than a feature");
    }

    if (node instanceof PlainLiteral)
      return new Boolean(Boolean.parseBoolean(((PlainLiteral) node)
          .getValue()));

    throw new RDFDataException("Cannot convert a " + node.getClass()
        + " to Boolean");
  }
View Full Code Here

    if (node instanceof PlainLiteral) {
      return toCalendar(node.asLiteral());
    }

    if (node instanceof LanguageTagLiteral) {
      throw new RDFDataException(
          "Cannot convert a language tagged literal to an Calendar - it makes no sense");
    }

    if (node instanceof DatatypeLiteral) {
      URI datatype = node.asDatatypeLiteral().getDatatype();
      if (datatype.equals(XSD._dateTime) || datatype.equals(XSD._date)
          || datatype.equals(XSD._time)) {
        return toCalendar(node.asDatatypeLiteral());
      } else {
        throw new RDFDataException("Cannot convert from datatype "
            + datatype + " to URI");
      }
    }

    throw new RDFDataException("Cannot convert from " + node.getClass()
        + " to Calendar");
  }
View Full Code Here

    if (node instanceof PlainLiteral) {
      return toByte(node.asLiteral());
    }

    if (node instanceof LanguageTagLiteral) {
      throw new RDFDataException(
          "Cannot convert a language tagged literal to an Byte - it makes no sense");
    }

    if (node instanceof DatatypeLiteral) {
      URI datatype = node.asDatatypeLiteral().getDatatype();
      if (datatype.equals(XSD._byte)) {
        return toByte(node.asDatatypeLiteral());
      } else {
        throw new RDFDataException("Cannot convert from datatype "
            + datatype + " to URI");
      }
    }

    throw new RDFDataException("Cannot convert from " + node.getClass()
        + " to Byte");
  }
View Full Code Here

    if (node instanceof PlainLiteral) {
      return toFloat(node.asLiteral());
    }

    if (node instanceof LanguageTagLiteral) {
      throw new RDFDataException(
          "Cannot convert a language tagged literal to a Float - it makes no sense");
    }

    if (node instanceof DatatypeLiteral) {
      URI datatype = node.asDatatypeLiteral().getDatatype();

      if (datatype.equals(XSD._float)) {
        return toFloat(node.asDatatypeLiteral());
      } else {
        throw new RDFDataException("Cannot convert from datatype "
            + datatype + " to URI");
      }
    }

    throw new RDFDataException("Cannot convert from " + node.getClass()
        + " to Float");
  }
View Full Code Here

    if (node instanceof PlainLiteral) {
      return toInteger(node.asLiteral());
    }

    if (node instanceof LanguageTagLiteral) {
      throw new RDFDataException(
          "Cannot convert a language tagged literal to an Integer - it makes no sense");
    }

    if (node instanceof DatatypeLiteral) {
      URI datatype = node.asDatatypeLiteral().getDatatype();

      // TODO add handling for XSD._nonPositiveInteger and other weird
      // types

      // Note: in general, xsd:integer cannot be handled by Java
     
      if (datatype.equals(XSD._int)) {
        return toInteger(node.asDatatypeLiteral());
      } else {
        throw new RDFDataException("Cannot convert from datatype "
            + datatype + " to URI");
      }
    }

    throw new RDFDataException("Cannot convert from " + node.getClass()
        + " to Integer");
  }
View Full Code Here

    if(node instanceof PlainLiteral) {
      return new URIImpl(node.asLiteral().getValue());
    }
   
    if(node instanceof LanguageTagLiteral) {
      throw new RDFDataException(
              "Cannot convert a language tagged literal to a URI - it makes no sense");
    }
   
    if(node instanceof DatatypeLiteral) {
      URI datatype = node.asDatatypeLiteral().getDatatype();
      if(datatype.equals(XSD._anyURI)) {
        return new URIImpl(node.asDatatypeLiteral().getValue());
      } else {
        throw new RDFDataException("Cannot convert from datatype " + datatype + " to URI");
      }
    }
   
    throw new RDFDataException("Cannot convert from " + node.getClass() + " to URI");
   
  }
View Full Code Here

TOP

Related Classes of org.ontoware.rdfreactor.runtime.RDFDataException

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.