iclatomic.java

来自「SRI international 发布的OAA框架软件」· Java 代码 · 共 158 行

JAVA
158
字号
package com.sri.oaa2.icl;

import java.util.Iterator;
import java.util.ListIterator;
import java.util.ArrayList;
import java.util.List;
import java.util.AbstractList;

class IclAtomic extends IclTerm 
{
  /**
   * A canonical, 'writeable' empty list.  Not using Collections.EMPTY_LIST
   * because we want IndexOutOfBoundsException, not UnsupportedMethodException.
   * 
   */
  static final List EMPTYLIST = new AbstractList() 
  {
    public Object get(int index) {
      throw new IndexOutOfBoundsException();
    }

    public int size() {
      return 0;
    }

    public Object set(int index, Object element) 
    {
      throw new IndexOutOfBoundsException();
    }
    
    public void add(int index, Object element) 
    {
      throw new IndexOutOfBoundsException();
    }
    
    public Object remove(int index) 
    {
      throw new IndexOutOfBoundsException();
    }
  };

  public IclAtomic() 
  {
    super();
  }

  public IclAtomic(int i) 
  {
    super(i);
  }

  public final boolean isAtomic() 
  {
    return true;
  }
  
  public final boolean isComposite() 
  {
    return false;
  }

  final void setChildren(ArrayList c) 
  {
    return;
  }

  // yeah, this is deprecated, but eventually it'll be protected
  public final ArrayList toArrayList() 
  {
    return null;
  }

  public final int getNumChildren() 
  {
    return 0;
  }

  public final void add(IclTerm n) throws UnsupportedOperationException
  {
    throw new UnsupportedOperationException("Cannot add child to atomic fact");
  }

  public final void add(int index, IclTerm n) throws UnsupportedOperationException
  {
    throw new UnsupportedOperationException("Cannot add child to atomic fact");
  }

  public final void addAll(IclTerm l) throws UnsupportedOperationException
  {
    throw new UnsupportedOperationException("Cannot add children to atomic fact");
  }

  public final void clearTerms() throws UnsupportedOperationException 
  {
    throw new UnsupportedOperationException("Cannot clear children of atomic fact");
  }

  protected final IclTerm getChild(int i) throws UnsupportedOperationException 
  {
    throw new IndexOutOfBoundsException("Atomic fact has no children");
  }

  public final IclTerm getTerm(int i) throws UnsupportedOperationException
  {
    throw new IndexOutOfBoundsException("Atomic fact has no children");
  }

  public final int size() 
  {
    return 0;
  }

  public final void removeAllUnifying(IclTerm n) throws UnsupportedOperationException
  {
    throw new UnsupportedOperationException("Cannot remove children from atomic fact");
  }

  public final IclTerm removeUnifying(IclTerm n) throws UnsupportedOperationException
  {
    throw new UnsupportedOperationException("Cannot remove children from atomic fact");
  }

  public final void removeElement(int i) throws UnsupportedOperationException
  {
    throw new UnsupportedOperationException("Cannot remove child from atomic fact");
  }

  public final void replaceUnifying(IclTerm target, IclTerm replacement) throws UnsupportedOperationException 
  {
    throw new UnsupportedOperationException("Cannot replace children of atomic fact");
  }

  public final void replaceElement(int target, IclTerm replacement) throws IndexOutOfBoundsException,  UnsupportedOperationException
  {
    throw new UnsupportedOperationException("Cannot replace child of atomic fact");
  }

  public final Iterator iterator() throws UnsupportedOperationException
  {
    return EMPTYLIST.iterator();
  }

  public ListIterator listIterator() throws UnsupportedOperationException
  {
    return EMPTYLIST.listIterator();
  }

  public final int hashCode() 
  {
    return (int)this.getCrc();
  }

  public boolean equals(Object o)
  {
    return false;
  }
}

⌨️ 快捷键说明

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