Package org.apache.uima.jcas.cas

Examples of org.apache.uima.jcas.cas.NonEmptyIntegerList


  }

  public void testGetNthIntegerList() throws Exception {
    try {

      NonEmptyIntegerList intList1 = new NonEmptyIntegerList(jcas);
      intList1.setHead(2);
      intList1.setTail(new EmptyIntegerList(jcas));
      NonEmptyIntegerList intList = new NonEmptyIntegerList(jcas);
      intList.setHead(1);
      intList.setTail(intList1);
      EmptyIntegerList emptyFsList = new EmptyIntegerList(jcas);

      try {
        emptyFsList.getNthElement(0);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_ON_EMPTY_LIST));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      try {
        intList.getNthElement(-1);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_NEGATIVE_INDEX));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      try {
        intList.getNthElement(2);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_PAST_END));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      assertTrue(1 == intList.getNthElement(0));
      assertTrue(2 == intList.getNthElement(1));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here


  }

  public void testGetNthIntegerList() throws Exception {
    try {

      NonEmptyIntegerList intList1 = new NonEmptyIntegerList(jcas);
      intList1.setHead(2);
      intList1.setTail(new EmptyIntegerList(jcas));
      NonEmptyIntegerList intList = new NonEmptyIntegerList(jcas);
      intList.setHead(1);
      intList.setTail(intList1);
      EmptyIntegerList emptyFsList = new EmptyIntegerList(jcas);

      try {
        emptyFsList.getNthElement(0);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_ON_EMPTY_LIST));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      try {
        intList.getNthElement(-1);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_NEGATIVE_INDEX));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      try {
        intList.getNthElement(2);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_PAST_END));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      assertTrue(1 == intList.getNthElement(0));
      assertTrue(2 == intList.getNthElement(1));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

  public static Collection<Integer> create(IntegerList aList) {
    List<Integer> data = new ArrayList<Integer>();
    IntegerList i = aList;
    while (i instanceof NonEmptyIntegerList) {
      NonEmptyIntegerList l = (NonEmptyIntegerList) i;
      data.add(l.getHead());
      i = l.getTail();
    }

    return asList(data.toArray(new Integer[data.size()]));
  }
View Full Code Here

  public static IntegerList createIntegerList(JCas aJCas, Collection<Integer> aCollection) {
    if (aCollection.isEmpty()) {
      return new EmptyIntegerList(aJCas);
    }

    NonEmptyIntegerList head = new NonEmptyIntegerList(aJCas);
    NonEmptyIntegerList list = head;
    Iterator<Integer> i = aCollection.iterator();
    while (i.hasNext()) {
      head.setHead(i.next());
      if (i.hasNext()) {
        head.setTail(new NonEmptyIntegerList(aJCas));
        head = (NonEmptyIntegerList) head.getTail();
      } else {
        head.setTail(new EmptyIntegerList(aJCas));
      }
    }
View Full Code Here

  }

  public void testGetNthIntegerList() throws Exception {
    try {

      NonEmptyIntegerList intList1 = new NonEmptyIntegerList(jcas);
      intList1.setHead(2);
      intList1.setTail(new EmptyIntegerList(jcas));
      NonEmptyIntegerList intList = new NonEmptyIntegerList(jcas);
      intList.setHead(1);
      intList.setTail(intList1);
      EmptyIntegerList emptyFsList = new EmptyIntegerList(jcas);

      try {
        emptyFsList.getNthElement(0);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_ON_EMPTY_LIST));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      try {
        intList.getNthElement(-1);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_NEGATIVE_INDEX));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      try {
        intList.getNthElement(2);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_PAST_END));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      assertTrue(1 == intList.getNthElement(0));
      assertTrue(2 == intList.getNthElement(1));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

  }

  public void testGetNthIntegerList() throws Exception {
    try {

      NonEmptyIntegerList intList1 = new NonEmptyIntegerList(jcas);
      intList1.setHead(2);
      intList1.setTail(new EmptyIntegerList(jcas));
      NonEmptyIntegerList intList = new NonEmptyIntegerList(jcas);
      intList.setHead(1);
      intList.setTail(intList1);
      EmptyIntegerList emptyFsList = new EmptyIntegerList(jcas);

      try {
        emptyFsList.getNthElement(0);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_ON_EMPTY_LIST));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      try {
        intList.getNthElement(-1);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_NEGATIVE_INDEX));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      try {
        intList.getNthElement(2);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_PAST_END));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      assertTrue(1 == intList.getNthElement(0));
      assertTrue(2 == intList.getNthElement(1));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

  }

  public void testGetNthIntegerList() throws Exception {
    try {

      NonEmptyIntegerList intList1 = new NonEmptyIntegerList(jcas);
      intList1.setHead(2);
      intList1.setTail(new EmptyIntegerList(jcas));
      NonEmptyIntegerList intList = new NonEmptyIntegerList(jcas);
      intList.setHead(1);
      intList.setTail(intList1);
      EmptyIntegerList emptyFsList = new EmptyIntegerList(jcas);

      try {
        emptyFsList.getNthElement(0);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_ON_EMPTY_LIST));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      try {
        intList.getNthElement(-1);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_NEGATIVE_INDEX));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      try {
        intList.getNthElement(2);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_PAST_END));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      assertTrue(1 == intList.getNthElement(0));
      assertTrue(2 == intList.getNthElement(1));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

  }

  public void testGetNthIntegerList() throws Exception {
    try {

      NonEmptyIntegerList intList1 = new NonEmptyIntegerList(jcas);
      intList1.setHead(2);
      intList1.setTail(new EmptyIntegerList(jcas));
      NonEmptyIntegerList intList = new NonEmptyIntegerList(jcas);
      intList.setHead(1);
      intList.setTail(intList1);
      EmptyIntegerList emptyFsList = new EmptyIntegerList(jcas);

      try {
        emptyFsList.getNthElement(0);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_ON_EMPTY_LIST));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      try {
        intList.getNthElement(-1);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_NEGATIVE_INDEX));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      try {
        intList.getNthElement(2);
        assertTrue(false); // error if we get here
      } catch (CASRuntimeException e) {
        assertTrue(e.getMessageKey().equals(CASRuntimeException.JCAS_GET_NTH_PAST_END));
        System.out.print("Expected Error: ");
        System.out.println(e.getMessage());
      }

      assertTrue(1 == intList.getNthElement(0));
      assertTrue(2 == intList.getNthElement(1));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

  public static Collection<Integer> create(IntegerList aList) {
    List<Integer> data = new ArrayList<Integer>();
    IntegerList i = aList;
    while (i instanceof NonEmptyIntegerList) {
      NonEmptyIntegerList l = (NonEmptyIntegerList) i;
      data.add(l.getHead());
      i = l.getTail();
    }

    return asList(data.toArray(new Integer[data.size()]));
  }
View Full Code Here

  public static IntegerList createIntegerList(JCas aJCas, Collection<Integer> aCollection) {
    if (aCollection.isEmpty()) {
      return new EmptyIntegerList(aJCas);
    }

    NonEmptyIntegerList head = new NonEmptyIntegerList(aJCas);
    NonEmptyIntegerList list = head;
    Iterator<Integer> i = aCollection.iterator();
    while (i.hasNext()) {
      head.setHead(i.next());
      if (i.hasNext()) {
        head.setTail(new NonEmptyIntegerList(aJCas));
        head = (NonEmptyIntegerList) head.getTail();
      } else {
        head.setTail(new EmptyIntegerList(aJCas));
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.uima.jcas.cas.NonEmptyIntegerList

Copyright © 2018 www.massapicom. 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.