Package org.apache.uima.jcas.cas

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


  }

  public void testGetNthFloatList() throws Exception {
    try {

      NonEmptyFloatList floatList1 = new NonEmptyFloatList(jcas);
      floatList1.setHead((float) 2.0);
      floatList1.setTail(new EmptyFloatList(jcas));
      NonEmptyFloatList floatList = new NonEmptyFloatList(jcas);
      floatList.setHead((float) 1.0);
      floatList.setTail(floatList1);
      EmptyFloatList emptyFsList = new EmptyFloatList(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 {
        floatList.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 {
        floatList.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.0 == floatList.getNthElement(0));
      assertTrue(2.0 == floatList.getNthElement(1));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here


  }

  public void testGetNthFloatList() throws Exception {
    try {

      NonEmptyFloatList floatList1 = new NonEmptyFloatList(jcas);
      floatList1.setHead((float) 2.0);
      floatList1.setTail(new EmptyFloatList(jcas));
      NonEmptyFloatList floatList = new NonEmptyFloatList(jcas);
      floatList.setHead((float) 1.0);
      floatList.setTail(floatList1);
      EmptyFloatList emptyFsList = new EmptyFloatList(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 {
        floatList.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 {
        floatList.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.0 == floatList.getNthElement(0));
      assertTrue(2.0 == floatList.getNthElement(1));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

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

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

  public static FloatList createFloatList(JCas aJCas, Collection<Float> aCollection) {
    if (aCollection.isEmpty()) {
      return new EmptyFloatList(aJCas);
    }

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

  }

  public void testGetNthFloatList() throws Exception {
    try {

      NonEmptyFloatList floatList1 = new NonEmptyFloatList(jcas);
      floatList1.setHead((float) 2.0);
      floatList1.setTail(new EmptyFloatList(jcas));
      NonEmptyFloatList floatList = new NonEmptyFloatList(jcas);
      floatList.setHead((float) 1.0);
      floatList.setTail(floatList1);
      EmptyFloatList emptyFsList = new EmptyFloatList(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 {
        floatList.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 {
        floatList.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.0 == floatList.getNthElement(0));
      assertTrue(2.0 == floatList.getNthElement(1));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

  }

  public void testGetNthFloatList() throws Exception {
    try {

      NonEmptyFloatList floatList1 = new NonEmptyFloatList(jcas);
      floatList1.setHead((float) 2.0);
      floatList1.setTail(new EmptyFloatList(jcas));
      NonEmptyFloatList floatList = new NonEmptyFloatList(jcas);
      floatList.setHead((float) 1.0);
      floatList.setTail(floatList1);
      EmptyFloatList emptyFsList = new EmptyFloatList(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 {
        floatList.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 {
        floatList.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.0 == floatList.getNthElement(0));
      assertTrue(2.0 == floatList.getNthElement(1));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

  }

  public void testGetNthFloatList() throws Exception {
    try {

      NonEmptyFloatList floatList1 = new NonEmptyFloatList(jcas);
      floatList1.setHead((float) 2.0);
      floatList1.setTail(new EmptyFloatList(jcas));
      NonEmptyFloatList floatList = new NonEmptyFloatList(jcas);
      floatList.setHead((float) 1.0);
      floatList.setTail(floatList1);
      EmptyFloatList emptyFsList = new EmptyFloatList(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 {
        floatList.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 {
        floatList.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.0 == floatList.getNthElement(0));
      assertTrue(2.0 == floatList.getNthElement(1));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

  }

  public void testGetNthFloatList() throws Exception {
    try {

      NonEmptyFloatList floatList1 = new NonEmptyFloatList(jcas);
      floatList1.setHead((float) 2.0);
      floatList1.setTail(new EmptyFloatList(jcas));
      NonEmptyFloatList floatList = new NonEmptyFloatList(jcas);
      floatList.setHead((float) 1.0);
      floatList.setTail(floatList1);
      EmptyFloatList emptyFsList = new EmptyFloatList(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 {
        floatList.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 {
        floatList.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.0 == floatList.getNthElement(0));
      assertTrue(2.0 == floatList.getNthElement(1));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

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

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

  public static FloatList createFloatList(JCas aJCas, Collection<Float> aCollection) {
    if (aCollection.isEmpty()) {
      return new EmptyFloatList(aJCas);
    }

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

TOP

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

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.