コード例 #1
0
  public static Byte node2Byte(Node node) {
    if (node == null) return null;

    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");
  }