001: package org.mandarax.lib;
002:
003: /*
004: * Copyright (C) 1999-2004 <a href="mailto:jens.dietrich@unforgettable.com">Jens Dietrich</a>
005: * Copyright (C) 1999-2004 <a href="mailto:a.kozlenkov@city.ac.uk">Alex Kozlenkov</a>
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */
021:
022: import org.mandarax.util.logging.LogCategories;
023: import org.mandarax.kernel.*;
024:
025: /**
026: * Prolog like cut predicate,
027: * @author <A HREF="mailto:jens.dietrich@unforgettable.com">Jens Dietrich</A>
028: * @author <A HREF="mailto:a.kozlenkov@city.ac.uk">Alex Kozlenkov</A>
029: * @version 3.4 <7 March 05>
030: * @since 2.1
031: * Prova re-integration modifications
032: * @author <A HREF="mailto:a.kozlenkov@city.ac.uk">Alex Kozlenkov</A>
033: * @version 3.4 <7 March 05>
034: */
035:
036: public class Cut implements Predicate {
037: // Further corrections 28/04/03
038: public transient int cutPredicate;
039:
040: private static final Class[] STRUCT = {};
041: private static final String[] SLOT_NAMES = {};
042:
043: /**
044: * Get the predicate structure.
045: * @return an array of types (classes)
046: */
047: public Class[] getStructure() {
048: return STRUCT;
049: }
050:
051: /**
052: * Indicates whether the predicate is executable.
053: * @return a boolean
054: */
055: public boolean isExecutable() {
056: return false;
057: }
058:
059: /**
060: * Get the name of the predicate.
061: * @return a string
062: */
063: public String getName() {
064: return "CUT[" + cutPredicate + "]";
065: }
066:
067: /**
068: * Perform the predicate.
069: * @param terms an array of term
070: * @param session a session object
071: * @return a string
072: */
073: public Object perform(Term[] terms, Session session) {
074: throw new UnsupportedOperationException(
075: "Cut does not support perform");
076: }
077:
078: /**
079: * Converts the object to a string.
080: * @return the string representation of this object
081: */
082: public String toString() {
083: return "CUT(" + cutPredicate + ")";
084: }
085:
086: /**
087: * Get the slot names.
088: * @return an array of strings, the length of the array is the same as
089: * the length of the array of terms (the structure of the predicate)
090: */
091: public String[] getSlotNames() {
092: return SLOT_NAMES;
093: }
094:
095: /**
096: * Set the slot names.
097: * @param names an array of strings, the length of the array is the same as
098: * the length of the array of terms (the structure of the predicate)
099: */
100: public void setSlotNames(String[] names) {
101: LogCategories.LOG_KB
102: .debug("Ignore attempt to set slot names for cut predicate");
103: // ignored
104: }
105:
106: /**
107: * Indicates whether the slot names can be modified.
108: * @return a boolean
109: */
110: public boolean slotNamesCanBeEdited() {
111: return false;
112: }
113: }
|