Example #1
0
 public void qdeOfLiabilityDetails() throws Exception {
   System.out.println(
       "----------------------------------------------------------------------------------------");
   System.out.print("\nSTEP - 3");
   System.out.println("    Enter customer's liability details :\n");
   textToSpeech.speak("Enter customer's liability details");
   textToSpeech.speak("Enter customer's liability details");
   System.out.println(
       "\nEmployment type :\n1- Home Maker\n2-Student\n3- Salaried\n4- Bussiness\n5- Other\n > ");
   textToSpeech.speak("Enter employment type");
   employmentType = getter.employmentTypeGetter();
   if (!("HOME MAKER".matches(employmentType))) {
     System.out.println("\nTotal Income(in Rs.) (in average) : ");
     textToSpeech.speak("Enter total income");
     totalIncome = getter.moneyGetter(0.0, 10000000.0);
     System.out.println("\nTotal expenses(in Rs.) (in average) : ");
     textToSpeech.speak("Enter total expenses");
     expenses = getter.expensesGetter(totalIncome);
     System.out.println("\nWorking company name : ");
     textToSpeech.speak("Enter working company name");
     companyName = getter.companyNameGetter();
     if (!("STUDENT".matches(employmentType))) {
       System.out.println("\nWorking experience : ");
       textToSpeech.speak("Enter working experience");
       experience = getter.experienceGetter();
     }
   }
 }
Example #2
0
 // sourcing() method for assigning general details of customer
 public void sourcing() throws Exception {
   System.out.println(
       "----------------------------------------------------------------------------------------");
   System.out.print("\nSTEP - 1");
   System.out.println("    Enter customer's general details :\n");
   textToSpeech.speak("Enter customer general details");
   System.out.print("First name : ");
   textToSpeech.speak("Enter first name");
   firstName = getter.nameGetter();
   System.out.print("Middle name : ");
   textToSpeech.speak("Enter middle Name");
   middleName = getter.middleNameGetter();
   System.out.print("Last name : ");
   textToSpeech.speak("Enter last name");
   lastName = getter.nameGetter();
   System.out.print("\nGender (M/Male OR F/Female) : ");
   textToSpeech.speak("enter your gender");
   gender = getter.genderGetter();
   System.out.print("\nEmail Id : ");
   textToSpeech.speak("Enter email Id");
   emailId = getter.emailIdGetter();
   System.out.print("\nDate of birth (in dd/mm/yyyy) : ");
   textToSpeech.speak("Enter Date of birth ");
   dateOfBirth = getter.dateGetter();
   System.out.print("\nMobile number (+91----------) : ");
   textToSpeech.speak("Enter mobile number ");
   mobileNo = getter.mobileNoGetter();
   System.out.print("\nPermanent address : ");
   textToSpeech.speak("Enter permanent address ");
   permanentAddress = getter.addressGetter();
   System.out.println(
       "\nApplyling for : \n1- (home) for HOME LOAN\n2- (auto) for AUTO LOAN :\n > ");
   textToSpeech.speak("enter loan type. 1- home loan, 2- auto loan");
   loanType = getter.loanTypeGetter();
 }
  private <K, V> void checkClosedRanges(
      Transaction txn,
      int i,
      int j,
      EntityIndex<K, V> index,
      SortedMap<Integer, SortedSet<Integer>> expected,
      Getter<K> kGetter,
      Getter<V> vGetter)
      throws DatabaseException {

    SortedMap<K, V> map = index.sortedMap();
    SortedMap<Integer, SortedSet<Integer>> rangeExpected;
    K k = kGetter.fromInt(i);
    K kPlusOne = kGetter.fromInt(i + 1);
    K l = kGetter.fromInt(j);
    K lPlusOne = kGetter.fromInt(j + 1);

    /* Sub range exclusive. */
    rangeExpected = expected.subMap(i + 1, j);
    checkCursor(
        index.keys(txn, k, false, l, false, null),
        map.subMap(kPlusOne, l).keySet(),
        true,
        expandKeys(rangeExpected),
        kGetter);
    checkCursor(
        index.entities(txn, k, false, l, false, null),
        map.subMap(kPlusOne, l).values(),
        false,
        expandValues(rangeExpected),
        vGetter);

    /* Sub range inclusive. */
    rangeExpected = expected.subMap(i, j + 1);
    checkCursor(
        index.keys(txn, k, true, l, true, null),
        map.subMap(k, lPlusOne).keySet(),
        true,
        expandKeys(rangeExpected),
        kGetter);
    checkCursor(
        index.entities(txn, k, true, l, true, null),
        map.subMap(k, lPlusOne).values(),
        false,
        expandValues(rangeExpected),
        vGetter);
  }
Example #4
0
 public void qdeOfLoanDetails() throws IOException, JavaLayerException {
   System.out.println(
       "----------------------------------------------------------------------------------------");
   System.out.print("\nSTEP - 4");
   System.out.println("    Enter customer's loan details :\n");
   textToSpeech.speak("Enter customer's loan details");
   System.out.println("\nLoan type : " + loanType);
   System.out.println("\nYour assets : ");
   textToSpeech.speak("Enter assets");
   assets = getter.assetsGetter();
   System.out.println("\nExpected cost of assets (in Rs.) : ");
   textToSpeech.speak("Enter expected cost of assets");
   assetsCost = getter.moneyGetter(100.0, 20000000.0);
   System.out.println("\nExpected loan amount (in Rs.) (in average) : ");
   textToSpeech.speak("Enter expected loan amount");
   loanAmount = getter.moneyGetter(1000.0, 10000000.0);
 }
Example #5
0
 /**
  * Play a sound only once, and allow it only once every interval. Very useful for sounds made
  * while enemies are on stage, since it won't play concurrent sounds.
  *
  * @param sound
  * @param volume
  * @param identifier
  * @param interval
  */
 public static void playSoundSingle(
     final Getter<Sound> getter, float volume, String identifier, long interval) {
   if (!Scheduler.isTracked(identifier, identifier)) {
     Sound sound = getter.get();
     sound.play(volume);
     Scheduler.track(identifier, identifier, interval);
   }
 }
  /** Returns OgnlRuntime.NotFound if the property does not exist. */
  public Object getPossibleProperty(Map context, Object target, String name) throws OgnlException {
    Object result;
    OgnlContext ognlContext = (OgnlContext) context;

    if (context.get("_compile") != null) {
      Getter getter = getGetter(ognlContext, target, name);

      if (getter != NotFoundGetter) {
        result = getter.get(ognlContext, target, name);
      } else {
        try {
          result = OgnlRuntime.getFieldValue(ognlContext, target, name, true);
        } catch (Exception ex) {
          throw new OgnlException(name, ex);
        }
      }
    } else {
      result = super.getPossibleProperty(context, target, name);
    }
    return result;
  }
Example #7
0
 // qdeOfPersonalDetails() method is used for assigning personal details of customer
 public void qdeOfPersonalDetails() throws IOException, JavaLayerException {
   System.out.println(
       "----------------------------------------------------------------------------------------");
   System.out.print("\nSTEP - 2");
   System.out.println("    Enter customer's personal details :\n");
   textToSpeech.speak("Enter customer's personal details");
   System.out.println("\nStatus :\n1- Married\n2- Unmarried\n > ");
   textToSpeech.speak("Married or unmarried");
   status = getter.statusGetter();
   if ("female".equalsIgnoreCase(gender) && "married".equalsIgnoreCase(status)) {
     System.out.println("Husband's name : ");
     textToSpeech.speak("enter husband's name");
     husbandName = getter.fatherOrHusbandNameGetter();
   } else {
     System.out.println("Father's name : ");
     textToSpeech.speak("enter father's name");
     fatherName = getter.fatherOrHusbandNameGetter();
   }
   System.out.println("Nationality :\n1- Indian\n2- Other\n > ");
   textToSpeech.speak("enter nationality");
   nationality = getter.nationalityGetter();
   System.out.println("Current address : ");
   textToSpeech.speak("enter current address");
   currentAddress = getter.addressGetter();
   System.out.println("PAN : ");
   textToSpeech.speak("enter personal account number");
   pan = getter.panGetter(lastName);
   System.out.println("Number of family members : ");
   textToSpeech.speak("enter number of family members");
   noOfFamilyMembers = getter.noOfFamilyMembersGetter();
   System.out.println(
       "Qualification :\n1- Nothing\n2- Matrics\n3- Intermediate\n4- Graduate\n4- Postgraduate\n5- Others\n > ");
   textToSpeech.speak("enter qualification");
   qualification = getter.qualificationGetter();
   if (!("NOTHING".equals(qualification))) {
     System.out.println("Year of qualification : ");
     textToSpeech.speak("enter year of qualification");
     qualification = getter.qualificationYearGetter();
   }
 }
 public T getValue(I obj) {
   return getter.get(obj);
 }
Example #9
0
 public T get() {
   return getter.get(); // Maybe an if-null approach would be faster?
 }
 void test(Getter g) {
   Getter result = g.get();
   GenericGetter gg = g.get(); // Also the base type
 }
Example #11
0
  /**
   * @param obj
   * @return
   * @throws MapperException
   */
  @SuppressWarnings("unchecked")
  public JSonNode create(final Object obj) throws MapperException {
    try {

      if (obj == null) {
        return new JSonValue(null);
      }
      final Class<? extends Object> clazz = obj.getClass();
      TypeMapper<?> mapper;
      if (clazz.isPrimitive()) {
        if (clazz == boolean.class) {
          return new JSonValue((Boolean) obj);
        } else if (clazz == char.class) {
          return new JSonValue(0 + ((Character) obj).charValue());
        } else if (clazz == byte.class) {
          return new JSonValue(((Byte) obj).longValue());
        } else if (clazz == short.class) {
          return new JSonValue(((Short) obj).longValue());
        } else if (clazz == int.class) {
          return new JSonValue(((Integer) obj).longValue());
        } else if (clazz == long.class) {
          return new JSonValue(((Long) obj).longValue());
        } else if (clazz == float.class) {
          return new JSonValue(((Float) obj).doubleValue());
        } else if (clazz == double.class) {
          return new JSonValue(((Double) obj).doubleValue());
        }
      } else if (clazz.isEnum()) {
        return new JSonValue(obj + "");
      } else if (obj instanceof Boolean) {
        return new JSonValue(((Boolean) obj).booleanValue());
      } else if (obj instanceof Character) {
        return new JSonValue(0 + ((Character) obj).charValue());
      } else if (obj instanceof Byte) {
        return new JSonValue(((Byte) obj).longValue());
      } else if (obj instanceof Short) {
        return new JSonValue(((Short) obj).longValue());
      } else if (obj instanceof Integer) {
        return new JSonValue(((Integer) obj).longValue());
      } else if (obj instanceof Long) {
        return new JSonValue(((Long) obj).longValue());
      } else if (obj instanceof Float) {
        return new JSonValue(((Float) obj).doubleValue());
      } else if (obj instanceof Double) {
        return new JSonValue(((Double) obj).doubleValue());

      } else if (obj instanceof String) {
        return new JSonValue((String) obj);
      } else if (obj instanceof Map) {

        final JSonObject ret = new JSonObject();
        Entry<Object, Object> next;
        for (final Iterator<Entry<Object, Object>> it =
                ((Map<Object, Object>) obj).entrySet().iterator();
            it.hasNext(); ) {
          next = it.next();
          if (!(next.getKey() instanceof String)) {
            throw new MapperException(
                "Map keys have to be Strings: "
                    + clazz
                    + " Keyclass:"
                    + (next.getKey() == null ? "<null>" : next.getKey().getClass()));
          }
          ret.put(next.getKey().toString(), create(next.getValue()));
        }
        return ret;
      } else if (obj instanceof Collection) {
        final JSonArray ret = new JSonArray();
        for (final Object o : (Collection<?>) obj) {
          ret.add(create(o));
        }
        return ret;
      } else if (clazz.isArray()) {
        final JSonArray ret = new JSonArray();
        for (int i = 0; i < Array.getLength(obj); i++) {
          ret.add(create(Array.get(obj, i)));
        }
        return ret;
      } else if (obj instanceof Class) {
        return new JSonValue(((Class<?>) obj).getName());
      } else if ((mapper = typeMapper.get(clazz)) != null) {
        return mapper.map(obj);
      } else /* if (obj instanceof Storable) */ {
        final ClassCache cc = ClassCache.getClassCache(clazz);
        final JSonObject ret = new JSonObject();
        for (final Getter g : cc.getGetter()) {

          ret.put(g.getKey(), create(g.getValue(obj)));
        }
        return ret;
      }
    } catch (final IllegalArgumentException e) {
      e.printStackTrace();
    } catch (final IllegalAccessException e) {
      e.printStackTrace();
    } catch (final InvocationTargetException e) {
      e.printStackTrace();
    } catch (final SecurityException e) {

      e.printStackTrace();
    } catch (final NoSuchMethodException e) {

      e.printStackTrace();
    }

    return null;
  }
  private <T> void checkCursor(
      EntityCursor<T> cursor,
      Collection<T> collection,
      boolean collectionIsKeySet,
      List<List<Integer>> expected,
      Getter<T> getter)
      throws DatabaseException {

    boolean first;
    boolean firstDup;
    Iterator<T> iterator = collection.iterator();

    for (List<Integer> dups : expected) {
      for (int i : dups) {
        T o = cursor.next();
        assertNotNull(o);
        assertEquals(i, getter.getKey(o));
        /* Value iterator over duplicates. */
        if (!collectionIsKeySet) {
          assertTrue(iterator.hasNext());
          o = iterator.next();
          assertNotNull(o);
          assertEquals(i, getter.getKey(o));
        }
      }
    }

    first = true;
    for (List<Integer> dups : expected) {
      firstDup = true;
      for (int i : dups) {
        T o = first ? cursor.first() : (firstDup ? cursor.next() : cursor.nextDup());
        assertNotNull(o);
        assertEquals(i, getter.getKey(o));
        first = false;
        firstDup = false;
      }
    }

    first = true;
    for (List<Integer> dups : expected) {
      if (!dups.isEmpty()) {
        int i = dups.get(0);
        T o = first ? cursor.first() : cursor.nextNoDup();
        assertNotNull(o);
        assertEquals(i, getter.getKey(o));
        /* Key iterator over non-duplicates. */
        if (collectionIsKeySet) {
          assertTrue(iterator.hasNext());
          o = iterator.next();
          assertNotNull(o);
          assertEquals(i, getter.getKey(o));
        }
        first = false;
      }
    }

    List<List<Integer>> reversed = new ArrayList<List<Integer>>();
    for (List<Integer> dups : expected) {
      ArrayList<Integer> reversedDups = new ArrayList<Integer>(dups);
      Collections.reverse(reversedDups);
      reversed.add(reversedDups);
    }
    Collections.reverse(reversed);

    first = true;
    for (List<Integer> dups : reversed) {
      for (int i : dups) {
        T o = first ? cursor.last() : cursor.prev();
        assertNotNull(o);
        assertEquals(i, getter.getKey(o));
        first = false;
      }
    }

    first = true;
    for (List<Integer> dups : reversed) {
      firstDup = true;
      for (int i : dups) {
        T o = first ? cursor.last() : (firstDup ? cursor.prev() : cursor.prevDup());
        assertNotNull(o);
        assertEquals(i, getter.getKey(o));
        first = false;
        firstDup = false;
      }
    }

    first = true;
    for (List<Integer> dups : reversed) {
      if (!dups.isEmpty()) {
        int i = dups.get(0);
        T o = first ? cursor.last() : cursor.prevNoDup();
        assertNotNull(o);
        assertEquals(i, getter.getKey(o));
        first = false;
      }
    }

    cursor.close();
  }
  private <K, V> void checkOpenRanges(
      Transaction txn,
      int i,
      EntityIndex<K, V> index,
      SortedMap<Integer, SortedSet<Integer>> expected,
      Getter<K> kGetter,
      Getter<V> vGetter)
      throws DatabaseException {

    SortedMap<K, V> map = index.sortedMap();
    SortedMap<Integer, SortedSet<Integer>> rangeExpected;
    K k = kGetter.fromInt(i);
    K kPlusOne = kGetter.fromInt(i + 1);

    /* Head range exclusive. */
    rangeExpected = expected.headMap(i);
    checkCursor(
        index.keys(txn, null, false, k, false, null),
        map.headMap(k).keySet(),
        true,
        expandKeys(rangeExpected),
        kGetter);
    checkCursor(
        index.entities(txn, null, false, k, false, null),
        map.headMap(k).values(),
        false,
        expandValues(rangeExpected),
        vGetter);

    /* Head range inclusive. */
    rangeExpected = expected.headMap(i + 1);
    checkCursor(
        index.keys(txn, null, false, k, true, null),
        map.headMap(kPlusOne).keySet(),
        true,
        expandKeys(rangeExpected),
        kGetter);
    checkCursor(
        index.entities(txn, null, false, k, true, null),
        map.headMap(kPlusOne).values(),
        false,
        expandValues(rangeExpected),
        vGetter);

    /* Tail range exclusive. */
    rangeExpected = expected.tailMap(i + 1);
    checkCursor(
        index.keys(txn, k, false, null, false, null),
        map.tailMap(kPlusOne).keySet(),
        true,
        expandKeys(rangeExpected),
        kGetter);
    checkCursor(
        index.entities(txn, k, false, null, false, null),
        map.tailMap(kPlusOne).values(),
        false,
        expandValues(rangeExpected),
        vGetter);

    /* Tail range inclusive. */
    rangeExpected = expected.tailMap(i);
    checkCursor(
        index.keys(txn, k, true, null, false, null),
        map.tailMap(k).keySet(),
        true,
        expandKeys(rangeExpected),
        kGetter);
    checkCursor(
        index.entities(txn, k, true, null, false, null),
        map.tailMap(k).values(),
        false,
        expandValues(rangeExpected),
        vGetter);
  }
  private <K, V> void checkIndex(
      EntityIndex<K, V> index,
      SortedMap<Integer, SortedSet<Integer>> expected,
      Getter<K> kGetter,
      Getter<V> vGetter)
      throws DatabaseException {

    SortedMap<K, V> map = index.sortedMap();

    Transaction txn = txnBegin();
    for (int i : expected.keySet()) {
      K k = kGetter.fromInt(i);
      SortedSet<Integer> dups = expected.get(i);
      if (dups.isEmpty()) {

        /* EntityIndex */
        V v = index.get(txn, k, null);
        assertNull(v);
        assertTrue(!index.contains(txn, k, null));

        /* Map/Collection */
        v = map.get(i);
        assertNull(v);
        assertTrue(!map.containsKey(i));
      } else {
        int j = dups.first();

        /* EntityIndex */
        V v = index.get(txn, k, null);
        assertNotNull(v);
        assertEquals(j, vGetter.getKey(v));
        assertTrue(index.contains(txn, k, null));

        /* Map/Collection */
        v = map.get(i);
        assertNotNull(v);
        assertEquals(j, vGetter.getKey(v));
        assertTrue(map.containsKey(i));
        assertTrue("" + i + ' ' + j + ' ' + v + ' ' + map, map.containsValue(v));
        assertTrue(map.keySet().contains(i));
        assertTrue(map.values().contains(v));
        assertTrue(map.entrySet().contains(new MapEntryParameter(i, v)));
      }
    }
    txnCommit(txn);

    int keysSize = expandKeySize(expected);
    int valuesSize = expandValueSize(expected);

    /* EntityIndex.count */
    assertEquals("keysSize=" + keysSize, valuesSize, index.count());

    /* Map/Collection size */
    assertEquals(valuesSize, map.size());
    assertEquals(valuesSize, map.values().size());
    assertEquals(valuesSize, map.entrySet().size());
    assertEquals(keysSize, map.keySet().size());

    /* Map/Collection isEmpty */
    assertEquals(valuesSize == 0, map.isEmpty());
    assertEquals(valuesSize == 0, map.values().isEmpty());
    assertEquals(valuesSize == 0, map.entrySet().isEmpty());
    assertEquals(keysSize == 0, map.keySet().isEmpty());

    txn = txnBeginCursor();

    /* Unconstrained cursors. */
    checkCursor(index.keys(txn, null), map.keySet(), true, expandKeys(expected), kGetter);
    checkCursor(index.entities(txn, null), map.values(), false, expandValues(expected), vGetter);

    /* Range cursors. */
    if (expected.isEmpty()) {
      checkOpenRanges(txn, 0, index, expected, kGetter, vGetter);
      checkClosedRanges(txn, 0, 1, index, expected, kGetter, vGetter);
    } else {
      int firstKey = expected.firstKey();
      int lastKey = expected.lastKey();
      for (int i = firstKey - 1; i <= lastKey + 1; i += 1) {
        checkOpenRanges(txn, i, index, expected, kGetter, vGetter);
        int j = i + 1;
        if (j < lastKey + 1) {
          checkClosedRanges(txn, i, j, index, expected, kGetter, vGetter);
        }
      }
    }

    txnCommit(txn);
  }