⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modelcom.java

📁 Jena推理机
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    
    public boolean contains( Resource s, Property p, String o, String l )
        { return contains( s, p, literal( o, l, false ) ); }
    
    public boolean contains(Resource s, Property p, Object o)
        { return contains( s, p, ensureRDFNode( o ) ); }
    
    public boolean containsAny( Model model ) 
        { return containsAnyThenClose( model.listStatements() ); }
    
    public boolean containsAll( Model model )  
        { return containsAllThenClose( model.listStatements() ); }
    
    protected boolean containsAnyThenClose( StmtIterator iter )
        { try { return containsAny( iter ); } finally { iter.close(); } }

    protected boolean containsAllThenClose( StmtIterator iter )
        { try { return containsAll( iter ); } finally { iter.close(); } }
    
    public boolean containsAny( StmtIterator iter ) 
        {
        while (iter.hasNext()) if (contains(iter.nextStatement())) return true;
        return false;
        }
    
    public boolean containsAll( StmtIterator iter )  
        {
        while (iter.hasNext()) if (!contains(iter.nextStatement())) return false;
        return true;
        }
    
    protected StmtIterator listStatements( Resource S, Property P, Node O )
        {
        return IteratorFactory.asStmtIterator
            ( graph.find( asNode( S ), asNode( P ), O ), this );
        }
    
    public StmtIterator listStatements( Resource S, Property P, RDFNode O )
        { return listStatements( S, P, asNode( O ) ); }
    
    public StmtIterator listStatements( Resource S, Property P, String O ) {
        return O == null ? listStatements(S, P, Node.ANY) 
                :  listStatements( S, P, Node.createLiteral( O ) ); 
    }
    
    public StmtIterator listStatements( Resource S, Property P, String O, String L ) {
        return O == null ? listStatements(S, P, Node.ANY) 
                :  listStatements( S, P, Node.createLiteral( O, L, false ) ); 
    }
    
    public StmtIterator listStatements( Resource S, Property P, boolean O )
        { return listStatements( S, P, String.valueOf( O ) ); }
    
    public StmtIterator listStatements( Resource S, Property P, long O )
        { return listStatements( S, P, String.valueOf( O ) ); }
    
    public StmtIterator listStatements( Resource S, Property P, char  O )
        { return listStatements( S, P, String.valueOf( O ) ); }
    
    public StmtIterator listStatements( Resource S, Property P, float O )
         { return listStatements( S, P, String.valueOf( O ) ); }
    
    public StmtIterator listStatements( Resource S, Property P, double  O )
        { return listStatements( S, P, String.valueOf( O ) ); }
        
    public ResIterator listSubjectsWithProperty( Property p, boolean o )
        { return listSubjectsWithProperty(p, String.valueOf( o ) ); }
    
    public ResIterator listSubjectsWithProperty( Property p, long o )
        { return listSubjectsWithProperty(p, String.valueOf( o ) ); }
    
    public ResIterator listSubjectsWithProperty( Property p, char o )
        { return listSubjectsWithProperty(p, String.valueOf( o ) ); }
    
    public ResIterator listSubjectsWithProperty( Property p, float o )
        { return listSubjectsWithProperty(p, String.valueOf( o ) ); }
    
    public ResIterator listSubjectsWithProperty( Property p, double o )
        { return listSubjectsWithProperty(p, String.valueOf( o ) ); }
    
    public ResIterator listSubjectsWithProperty( Property p, String o )
        { return listSubjectsWithProperty( p, o, "" ); }
    
    public ResIterator listSubjectsWithProperty( Property p, String o, String l )
        { return listSubjectsWithProperty(p, literal( o, l, false ) ); }
    
    public ResIterator listSubjectsWithProperty( Property p, Object o )
        { return listSubjectsWithProperty( p, ensureRDFNode( o ) ); }
    
    public Resource createResource( Resource type )  
        { return createResource().addProperty( RDF.type, type ); }
    
    public Resource createResource( String uri,Resource type )
        { return getResource( uri ).addProperty( RDF.type, type ); }
    
    public Resource createResource( ResourceF f )  
        { return createResource( null, f ); }
    
    public Resource createResource( AnonId id )
        { return new ResourceImpl( id, this ); }
        
    public Resource createResource( String uri, ResourceF f )  
        { return f.createResource( createResource( uri ) ); }
    
 
    /** create a type literal from a boolean value.
     *
     * <p> The value is converted to a string using its <CODE>toString</CODE>
     * method. </p>
     * @param v the value of the literal
     * 
     * @return a new literal representing the value v
     */
    public Literal createTypedLiteral( boolean v )  {
        return createTypedLiteral( new Boolean( v ) );
    }
    
    /** create a typed literal from an integer value.
     *
     * @param v the value of the literal
     * 
     * @return a new literal representing the value v
     */   
    public Literal createTypedLiteral(int v)   {
        return createTypedLiteral(new Integer(v));
    }
    
    /** create a typed literal from a long integer value.
     *
     * @param v the value of the literal
     * 
     * @return a new literal representing the value v
     */   
    public Literal createTypedLiteral(long v)   {
        return createTypedLiteral(new Long(v));
    }
    
    /** create a typed literal from a char value.
     *
     * @param v the value of the literal
     * 
     * @return a new literal representing the value v
     */
    public Literal createTypedLiteral(char v)  {
        return createTypedLiteral(new Character(v));
    }
    
    /** create a typed literal from a float value.
     *
     * @param v the value of the literal
     * 
     * @return a new literal representing the value v
     */
    public Literal createTypedLiteral(float v)  {
        return createTypedLiteral(new Float(v));
    }
    
    /** create a typed literal from a double value.
     *
     * @param v the value of the literal
     * 
     * @return a new literal representing the value v
     */
    public Literal createTypedLiteral(double v)  {
        return createTypedLiteral(new Double(v));
    }
    
    /** create a typed literal from a String value.
     *
     * @param v the value of the literal
     * 
     * @return a new literal representing the value v
     */
    public Literal createTypedLiteral(String v)  {
        LiteralLabel ll = new LiteralLabel(v);
        return new LiteralImpl(Node.createLiteral(ll), this);
    }

    /**
     * Create a typed literal xsd:dateTime from a Calendar object. 
     */
    public Literal createTypedLiteral(Calendar cal) {
        Object value = new XSDDateTime(cal);
        LiteralLabel ll = new LiteralLabel(value, "", XSDDatatype.XSDdateTime);
        return new LiteralImpl(Node.createLiteral(ll), this);
        
    }
    
    /**
     * Build a typed literal from its lexical form. The
     * lexical form will be parsed now and the value stored. If
     * the form is not legal this will throw an exception.
     * 
     * @param lex the lexical form of the literal
     * @param dtype the type of the literal, null for old style "plain" literals
     * @throws DatatypeFormatException if lex is not a legal form of dtype
     */
    public Literal createTypedLiteral(String lex, RDFDatatype dtype) 
                                        throws DatatypeFormatException {
        return new LiteralImpl( Node.createLiteral( lex, "", dtype ), this);
    }
    
    /**
     * Build a typed literal from its value form.
     * 
     * @param value the value of the literal
     * @param dtype the type of the literal, null for old style "plain" literals
     */
    public Literal createTypedLiteral(Object value, RDFDatatype dtype) {
        LiteralLabel ll = new LiteralLabel(value, "", dtype);
        return new LiteralImpl( Node.createLiteral(ll), this );
    }

    /**
     * Build a typed literal from its lexical form. The
     * lexical form will be parsed now and the value stored. If
     * the form is not legal this will throw an exception.
     * 
     * @param lex the lexical form of the literal
     * @param typeURI the uri of the type of the literal, null for old style "plain" literals
     * @throws DatatypeFormatException if lex is not a legal form of dtype
     */
    public Literal createTypedLiteral(String lex, String typeURI)  {
        RDFDatatype dt = TypeMapper.getInstance().getSafeTypeByName(typeURI);
        LiteralLabel ll = LiteralLabel.createLiteralLabel( lex, "", dt );
        return new LiteralImpl( Node.createLiteral(ll), this );
    }
        
    /**
     * Build a typed literal from its value form.
     * 
     * @param value the value of the literal
     * @param typeURI the URI of the type of the literal, null for old style "plain" literals
     */
    public Literal createTypedLiteral(Object value, String typeURI) {
        RDFDatatype dt = TypeMapper.getInstance().getSafeTypeByName(typeURI);
        LiteralLabel ll = new LiteralLabel(value, "", dt);
        return new LiteralImpl(Node.createLiteral(ll), this);
    }
        
    /**
     * Build a typed literal label from its value form using
     * whatever datatype is currently registered as the the default
     * representation for this java class. No language tag is supplied.
     * @param value the literal value to encapsulate
     */
    public Literal createTypedLiteral( Object value ) 
        {
        // Catch special case of a Calendar which we want to act as if it were an XSDDateTime
        if (value instanceof Calendar) 
            return createTypedLiteral( (Calendar)value );
        LiteralLabel ll = new LiteralLabel( value );
        return new LiteralImpl( Node.createLiteral( ll ), this);
        }

    public Literal createLiteral( boolean v )  
        { return createLiteral( String.valueOf( v ), "" ); }
    
    public Literal createLiteral( int v )  
        { return createLiteral( String.valueOf( v ), "" ); }
    
    public Literal createLiteral( long v )  
        { return createLiteral( String.valueOf( v ), "" ); }
    
    public Literal createLiteral( char v )  
        { return createLiteral( String.valueOf( v ), "" ); }
    
    public Literal createLiteral( float v )  
        { return createLiteral( String.valueOf( v ), "" ); }
    
    public Literal createLiteral( double v )  
        { return createLiteral( String.valueOf( v ), "" ); }
    
    public Literal createLiteral( String v )  
        { return createLiteral( v, "" ); }
    
    public Literal createLiteral( String v, String l )  
        { return literal( v, l, false ); }
    
    public Literal createLiteral( String v, boolean wellFormed ) 
        { return literal( v, "", wellFormed ); }
    
    public Literal createLiteral(String v, String l, boolean wellFormed) 
        { return literal( v, l, wellFormed ); }
    
    public Literal createLiteral( Object v )  
        { return createLiteral( v.toString(), "" ); }
    
    public Statement createStatement( Resource r, Property p, boolean o )
        { return createStatement( r, p, createLiteral( o ) ); }
    
    public Statement createStatement( Resource r, Property p, long o )
        { return createStatement( r, p, createLiteral( o ) ); }
    
    public Statement createStatement( Resource r, Property p, char o )
        { return createStatement( r, p, createLiteral( o ) ); }
    
    public Statement createStatement( Resource r, Property p, float o )
        { return createStatement( r, p, createLiteral( o ) ); }
    
    public Statement createStatement( Resource r, Property p, double o )
        { return createStatement( r, p, createLiteral( o ) ); }
    
    public Statement createStatement( Resource r, Property p, String o )
        { return createStatement( r, p, createLiteral( o ) ); }
    
    public Statement createStatement(Resource r, Property p, Object o)
        { return createStatement( r, p, ensureRDFNode( o ) ); }
    
    public Statement createStatement
        ( Resource r, Property p, String o, boolean wellFormed )  
        { return createStatement( r, p, o, "", wellFormed ); }
    
    public Statement createStatement(Resource r, Property p, String o, String l)
        { return createStatement( r, p, o, l, false ); }
    
    public Statement createStatement
        ( Resource r, Property p, String o, String l, boolean wellFormed )  
        { return createStatement( r, p, literal( o, l, wellFormed ) ); }
    
    public Bag createBag()  
        { return createBag( null ); }
    
    public Alt createAlt()  
        { return createAlt( null ); }
    
    public Seq createSeq()  
        { return createSeq( null ); }
    
    /**
        Answer a (the) new empty list
        @return An RDF-encoded list of no elements (ie nil)
    */
    public RDFList createList() 
        { return (RDFList) getResource( RDF.nil.getURI() ).as( RDFList.class ); }
    
    
    /**
     * <p>Answer a new list containing the resources from the given iterator, in order.</p>
     * @param members An iterator, each value of which is expected to be an RDFNode.
     * @return An RDF-encoded list of the elements of the iterator
     */
    public RDFList createList( Iterator members ) {
        RDFList list = createList();
        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -