Package com.hp.jena.rules.functions.jena2

Source Code of com.hp.jena.rules.functions.jena2.IsDType

/**
*
*/
package com.hp.jena.rules.functions.jena2;

import java.util.List;

import com.hp.jena.datatypes.RDFDatatype;
import com.hp.jena.datatypes.TypeMapper;
import com.hp.jena.graph.Node;
import com.hp.jena.rules.functions.ApplyableBase;
import com.hp.jena.rules.retelike.impl.Bindings;
import com.hp.jena.rules.retelike.impl.ExecContext;

public class IsDType extends ApplyableBase
{
protected final Node val, type;

public IsDType( List<Node> nargs )
    { val = nargs.get( 0 ); type = nargs.get( 1 ); }

@Override public boolean evalBool( ExecContext c, Bindings<Node, Node> item )
    {
    Node v = eval( item, val ), t = eval( item, type );
    if (!t.isIRI()) return false;
    if (v.isBlank()) return true;
    if (v.isLiteral())
        {
        RDFDatatype dtype = TypeMapper.getInstance().getSafeTypeByName(t.getIRI().asString() );
        RDFDatatype vType = v.getLiteralDatatype();
        return dtype != null && dtype.isValidLiteral( t.asLiteral() );
        }
    else
        return false;
    }
}
TOP

Related Classes of com.hp.jena.rules.functions.jena2.IsDType

TOP
Copyright © 2018 www.massapi.com. 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.