Package org.mindswap.pellet.exceptions

Examples of org.mindswap.pellet.exceptions.InternalReasonerException


  private static class ResolveURI implements StringToStringFunction {

    public String apply(String... args) {
      if( args.length != 2 )
        throw new InternalReasonerException( "ResolveURI takes two and only two arguments" );

      URI relativeURI, baseURI;
      String relative = args[0];
      String base = args[1];

      // According to
      // http://www.w3.org/TR/xpath-functions/#func-resolve-uri, if
      // relative is an empty sequence, the empty sequence is returned
      if( relative.length() == 0 )
        return relative;

      try {
        relativeURI = new URI( relative );

        // If relative is absolute it is returned unchanged
        if( relativeURI.isAbsolute() )
          return relative;
      } catch( URISyntaxException e ) {
        throw new InternalReasonerException( "Relative URI reference is not a valid URI" );
      }

      try {
        baseURI = new URI( base );

      } catch( URISyntaxException e ) {
        throw new InternalReasonerException( "Base URI reference is not a valid URI" );
      }

      if( relativeURI == null )
        throw new InternalReasonerException( "Error in resolving relative URI" );
      if( baseURI == null )
        throw new InternalReasonerException( "Error in resolving base URI" );

      try {
        URI ret = new URI( baseURI.toASCIIString() + relativeURI.toASCIIString() );

        return ret.toASCIIString();
      } catch( URISyntaxException e ) {
        throw new InternalReasonerException(
            "Evaluation of base and relative URI is not a URI" );
      }
    }
View Full Code Here


        if( PelletOptions.INVALID_LITERAL_AS_INCONSISTENCY ) {
          canonical = literal;
        }
        else {
          log.severe( msg );
          throw new InternalReasonerException( msg, e );
        }
      } catch( UnrecognizedDatatypeException e ) {
        final String msg = format(
            "Unrecognized datatype in literal appearing (%s) in SWRL data constant: %s",
            literal, e.getMessage() );
        log.severe( msg );
        throw new InternalReasonerException( msg, e );
      }

      abox.copyOnWrite();
      value = abox.getLiteral( canonical );
      if ( value == null )
View Full Code Here

  private static class AnyURI implements StringToStringFunction {

    public String apply(String... args) {
      if( args.length != 6 )
        throw new InternalReasonerException( "AnyURI wrong number of arguments" );

      String schema = args[0];
      String host = args[1];
      String port = args[2];
      String path = args[3];
      String query = args[4];
      String fragment = args[5];

      if( !schema.endsWith( ":" ) )
        schema += ":";

      if( !host.startsWith( "//" ) )
        host = "//" + host;

      if( port.length() > 0 && !port.startsWith( ":" ) )
        port = ":" + port;

      if( path.length() > 0 && !path.startsWith( "/" ) )
        path = "/" + path;
     
      if( query.length() > 0 && !query.startsWith( "?" ) )
        query = "?" + query;

      if( fragment.length() > 0 && !fragment.startsWith( "#" ) )
        fragment = "#" + fragment;
     
      try {
        URI uri = new URI( schema + host + port + path + query + fragment );

        return uri.toASCIIString();
      } catch( URISyntaxException e ) {
        throw new InternalReasonerException( "Returned string is not a URI" );
      }
    }
View Full Code Here

  public void rebind(VariableBinding newBinding) {
    Literal dValue = newBinding.get( atom.getArgument() );

    if( dValue == null ) {
      throw new InternalReasonerException(
          "DataRangeBindingHelper cannot generate bindings for " + atom );
    }

    try {
      hasNext = dtReasoner.isSatisfiable( Collections.singleton( atom.getPredicate() ),
          dValue.getValue() );
    } catch( DatatypeReasonerException e ) {
      final String msg = "Unexpected datatype reasoner exception: " + e.getMessage();
      log.severe( msg );
      throw new InternalReasonerException( e );
    }
  }
View Full Code Here

     * @param chain List of role names of at least length 2.
     * @param ds
     */
    public void addSubRoleChain( ATermList chain, DependencySet ds) {
        if( chain.isEmpty() )
            throw new InternalReasonerException( "Adding a subproperty chain that is empty!" );
        else if( chain.getLength() == 1 )
            throw new InternalReasonerException( "Adding a subproperty chain that has a single element!" );

        subRoleChains = SetUtils.add( chain, subRoleChains );
        explainSub.put(chain, ds);
        setSimple( false );

View Full Code Here

      break;
    case FLOAT:
      visitor.visit( floatArgs );
      break;
    default:
      throw new InternalReasonerException( "Cannot visit type " + type );
    }
  } 
View Full Code Here

    else if ( num instanceof Float )
      return Type.FLOAT;
    else if ( num instanceof Double )
      return Type.DOUBLE;
    else
      throw new InternalReasonerException( "Unexpected numeric type '" + num.getClass() +"': " + num);
  }
View Full Code Here

      break;
    case FLOAT:
      floatArgs = new Float[ length ];
      break;
    default:
      throw new InternalReasonerException( "Faulty switch: Don't know how to handle '" + type + "'." );
    }
  }
View Full Code Here

   * Converts the number to that type, and assigns it to the given position in the
   * array associated with that type.
   */
  private void promote( Number arg, int position, Type type2 ) {
    if ( type2.isLessThan( Type.BIGINTEGER ) ) {
      throw new InternalReasonerException( "Cannot promote to anything less than BigInteger" );
    }
    Type type1 = findType( arg );
   
    if ( type2 == Type.DOUBLE ) {
      doubleArgs[position] = arg.doubleValue();
    }
    else if ( type2 == Type.FLOAT ) {
      floatArgs[position] = arg.floatValue();
    }
    else if ( type2 == Type.BIGDECIMAL ) {
      if ( type1 == Type.BIGDECIMAL ) {
        decimalArgs[position] = (BigDecimal) arg;
      }
      else if ( type1 == Type.BIGINTEGER ) {
        decimalArgs[position] = new BigDecimal( (BigInteger) arg, 0, MathContext.DECIMAL128 );
      }
      else if ( type1.isLessThan( Type.BIGINTEGER ) ) {
        decimalArgs[position] = new BigDecimal( arg.longValue(), MathContext.DECIMAL128 );
      }
      else {
        throw new InternalReasonerException( "Do not know how to convert " + type1 + " to BigDecimal.");
      }
    }
    else if ( type2 == Type.BIGINTEGER ) {
      if ( type1 == Type.BIGINTEGER ) {
        bigIntArgs[position] = (BigInteger) arg;
      }
      else if ( type1.isLessThan( Type.BIGINTEGER ) ) {
        bigIntArgs[position] = new BigDecimal( arg.longValue(), MathContext.DECIMAL128 ).toBigInteger();
      } else {
        throw new InternalReasonerException( "Do not know how to convert " + type1 + " to BigInteger.");
      }
    } else {
      throw new InternalReasonerException( "Do not know how to promote numbers to type " + type2 );
    }
  }
View Full Code Here

    public TestProperty(ATermAppl p, AtomIObject arg1, S arg2) {
      super( arg1, arg2 );
      r = abox.getRole( p );
      if( r == null ) {
        throw new InternalReasonerException( "Cannot retreive role!: " + p );
      }
    }
View Full Code Here

TOP

Related Classes of org.mindswap.pellet.exceptions.InternalReasonerException

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.