RDFPredicate.java :  » Rule-Engine » Mandarax » org » mandarax » rdf » Java Open Source

Java Open Source » Rule Engine » Mandarax 
Mandarax » org » mandarax » rdf » RDFPredicate.java
/*
 * Copyright (C) 1999-2004 <a href="mailto:mandarax@jbdietrich.com">Jens Dietrich</a>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.mandarax.rdf;

import org.mandarax.kernel.*;


/** 
 * RDF predicate implementation.  
 * @author <A HREF="mailto:j.b.dietrich@massey.ac.nz">Jens Dietrich</A> <A HREF="mailto:paschke@in.tum.de">Adrian Paschke</A>
 * @version 1.1 <01 August 2004>
 * @since 0.1
 */

public class RDFPredicate implements Predicate,RDFLogger {
  private static final String[] slotNames = {"subject","object"};
  // TODO inventing our own classes Resource and Literals seems to be the easiest way, but is memory intensive
  // should we just use the respective JENA types??
  private static final Class[] structure = {Object.class,Object.class};
  
  private String nameSpace = null;
  private String localName = null;

  /**
   * Constructor.
   */
  public RDFPredicate() {
    super();
  }
  
  /**
   * Constructor.
   * @param nameSpace a name space
   * @param localName a local name
   */
  public RDFPredicate(String nameSpace,String localName) {
    super();
    this.nameSpace = nameSpace;
    this.localName = localName;
  }
  
  /**
   * Get the slot names.
   * @return an array of strings
   */
  public String[] getSlotNames() {
    return slotNames;
  }
  /**
   * Set the slot names. This method is ignored, the slot names are fixed
   * @param names an array of strings
   */
  public void setSlotNames(String[] names) {
    throw new UnsupportedOperationException("The slot names cannot be changed ");
  }
  /**
   * Indicates whether the slot names can be modified.
   * @return a boolean
   */
  public boolean slotNamesCanBeEdited() {
    return false;
  }
    /**
     * Get the name of the object.
     * @return the name of the constructor
     */
    public String getName() {
      return (nameSpace==null?"":nameSpace)+localName;
    }

    /**
     * Get the type structure of the object, e.g. the types of terms
     * that can be used with this constructor.
     * @return the structure of this constructor
     */
    public Class[] getStructure() {

      return structure;
    }

    /**
     * Perform the function or predicate using an array of terms as parameters.
     * @return the result of the perform operation
     * @param parameter an array of terms
     * @param session a session object
     * @throws java.lang.UnsupportedOperationException thrown if this constructor does not have a sematics and this operation cannot be supported
     * @throws java.lang.IllegalArgumentException
     */
    public Object perform(Term[] parameter,Session session) throws IllegalArgumentException, UnsupportedOperationException {
      throw new UnsupportedOperationException("RDF Predicates do not support \"perform\"");
    }
  /**
   * Indicates whether this predicate is executable.
   * @return a boolean
   */
  public boolean isExecutable() {
    return false;
  }
  /**
   * Get the local name.
   * @return Returns the localName.
   */
  public String getLocalName() {
    return localName;
  }
  /**
   * Set the local name.
   * @param localName The localName to set.
   */
  public void setLocalName(String localName) {
    this.localName = localName;
  }
  /**
   * Get the name space.
   * @return Returns the nameSpace.
   */
  public String getNameSpace() {
    return nameSpace;
  }
  /**
   * Set the name space.
   * @param nameSpace The nameSpace to set.
   */
  public void setNameSpace(String nameSpace) {
    this.nameSpace = nameSpace;
  }
  /**
   * Convert this object to a string.
   * @return the string representation of the object.
   */
  public String toString() {
    return new StringBuffer().append("anRDFPredicate(")
      .append(nameSpace==null?"":nameSpace)
      .append(localName)
      .append(')')
      .toString();
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.