public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindInt16DefMaxValue.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamInt16DefObj) {
      Short maxValue = ((ICFBamInt16DefObj) genDef).getOptionalMaxValue();
      if (maxValue == null) {
        ret = null;
      } else {
        ret = maxValue.toString();
      }
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(), "expandBody", "genContext.getGenDef()", genDef, "ICFBamInt16DefObj");
    }

    return (ret);
  }
  public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFFreeSwitchMssCFBindISOLanguageISOCountryId.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFFreeSwitchISOLanguageObj) {
      Short iSOCountryId = ((ICFFreeSwitchISOLanguageObj) genDef).getOptionalISOCountryId();
      if (iSOCountryId == null) {
        ret = null;
      } else {
        ret = iSOCountryId.toString();
      }
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(),
              "expandBody",
              "genContext.getGenDef()",
              genDef,
              "ICFFreeSwitchISOLanguageObj");
    }

    return (ret);
  }
  public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFAccMssCFBindAccountChequeNumDigits.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFAccAccountObj) {
      short chequeNumDigits = ((ICFAccAccountObj) genDef).getRequiredChequeNumDigits();
      ret = Short.toString(chequeNumDigits);
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(), "expandBody", "genContext.getGenDef()", genDef, "ICFAccAccountObj");
    }

    return (ret);
  }
  public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFFreeSwitchMssCFBindISOTimezoneTZMinOffset.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFFreeSwitchISOTimezoneObj) {
      short tZMinOffset = ((ICFFreeSwitchISOTimezoneObj) genDef).getRequiredTZMinOffset();
      ret = Short.toString(tZMinOffset);
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(),
              "expandBody",
              "genContext.getGenDef()",
              genDef,
              "ICFFreeSwitchISOTimezoneObj");
    }

    return (ret);
  }
  public String expandBody(MssCFGenContext genContext) {
    final String S_ProcName = "CFBamMssCFBindISOCountryCurrencyISOCurrencyId.expandBody() ";

    if (genContext == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext");
    }

    ICFLibAnyObj genDef = genContext.getGenDef();
    if (genDef == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newNullArgumentException(getClass(), "expandBody", 1, "genContext.getGenDef()");
    }

    String ret;

    if (genDef instanceof ICFBamISOCountryCurrencyObj) {
      short iSOCurrencyId = ((ICFBamISOCountryCurrencyObj) genDef).getRequiredISOCurrencyId();
      ret = Short.toString(iSOCurrencyId);
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(
              getClass(),
              "expandBody",
              "genContext.getGenDef()",
              genDef,
              "ICFBamISOCountryCurrencyObj");
    }

    return (ret);
  }
 public CFSecurityCursor openISOTimezoneCursorByOffsetIdx(
     CFSecurityAuthorization Authorization, short TZHourOffset, short TZMinOffset) {
   String sql =
       getSqlSelectISOTimezoneBuff()
           + "WHERE "
           + "itzn.TZHourOffset = "
           + Short.toString(TZHourOffset)
           + " "
           + "AND "
           + "itzn.TZMinOffset = "
           + Short.toString(TZMinOffset)
           + " "
           + "ORDER BY "
           + "itzn.ISOTimezoneId ASC";
   CFDbTestCursor cursor = new CFDbTestPgSqlCursor(Authorization, schema, sql);
   return (cursor);
 }
 public String toString() {
   String ret =
       "<CFSecurityISOCountryLanguageByCountryIdx"
           + " RequiredISOCountryId="
           + "\""
           + Short.toString(getRequiredISOCountryId())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFInternetURLProtocolHPKey"
           + " RequiredURLProtocolId="
           + "\""
           + Short.toString(getRequiredURLProtocolId())
           + "\""
           + " RequiredRevision=\""
           + Integer.toString(getRequiredRevision())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFBamISOLanguageHPKey"
           + " RequiredId="
           + "\""
           + Short.toString(getRequiredId())
           + "\""
           + " RequiredRevision=\""
           + Integer.toString(getRequiredRevision())
           + "\""
           + "/>";
   return (ret);
 }
 public String toString() {
   String ret =
       "<CFCrmClusterId32Gen"
           + " RequiredId="
           + "\""
           + Long.toString(getRequiredId())
           + "\""
           + ", SliceId=\""
           + Short.toString(getRequiredSliceId())
           + "\""
           + ", NextId=\""
           + Integer.toString(nextId)
           + "\"/>";
   return (ret);
 }
 public CFSecurityCursor openISOCountryLanguageCursorByLanguageIdx(
     CFSecurityAuthorization Authorization, short ISOLanguageId) {
   String sql =
       getSqlSelectISOCountryLanguageBuff()
           + "WHERE "
           + "iscl.ISOLanguageId = "
           + Short.toString(ISOLanguageId)
           + " "
           + "ORDER BY "
           + "iscl.ISOCountryId ASC"
           + ", "
           + "iscl.ISOLanguageId ASC";
   CFFreeSwitchCursor cursor = new CFFreeSwitchPgSqlCursor(Authorization, schema, sql);
   return (cursor);
 }
 public String toString() {
   String ret =
       "<CFAsteriskClusterId64Gen"
           + " RequiredId="
           + "\""
           + Long.toString(getRequiredId())
           + "\""
           + ", SliceId=\""
           + Short.toString(getRequiredSliceId())
           + "\""
           + ", NextId=\""
           + Long.toString(nextId)
           + "\"/>";
   return (ret);
 }
 public CFSecurityCursor openISOCountryCurrencyCursorByCurrencyIdx(
     CFSecurityAuthorization Authorization, short ISOCurrencyId) {
   String sql =
       getSqlSelectISOCountryCurrencyBuff()
           + " WHERE "
           + "iccy.isocurrencyid = "
           + Short.toString(ISOCurrencyId)
           + " "
           + "ORDER BY "
           + "iccy.ISOCountryId ASC"
           + ", "
           + "iccy.ISOCurrencyId ASC";
   CFBamCursor cursor = new CFBamMSSqlCursor(Authorization, schema, sql);
   return (cursor);
 }
 public boolean addMeIfNeccessary(
     PhysicalAgent source, Physical target, boolean makeLongLasting, int asLevel, short maxTicks) {
   final List<Ability> V = getMySpellsV();
   if ((target == null)
       || (V.size() == 0)
       || ((compiledMask != null) && (!CMLib.masking().maskCheck(compiledMask, target, true))))
     return false;
   final List VTOO = convertToV2(V, target);
   if (VTOO.size() == 0) return false;
   final MOB qualMOB = getInvokerMOB(source, target);
   for (int v = 0; v < VTOO.size(); v += 2) {
     final Ability A = (Ability) VTOO.get(v);
     final Vector V2 = (Vector) VTOO.get(v + 1);
     if (level >= 0) asLevel = level;
     else if (asLevel <= 0) asLevel = (affected != null) ? affected.phyStats().level() : 0;
     A.invoke(qualMOB, V2, target, true, asLevel);
     final Ability EA = target.fetchEffect(A.ID());
     lastMOB = target;
     // this needs to go here because otherwise it makes non-item-invoked spells long lasting,
     // which means they dont go away when item is removed.
     if (EA != null) {
       if ((maxTicks > 0)
           && (maxTicks < Short.MAX_VALUE)
           && (CMath.s_int(EA.getStat("TICKDOWN")) > maxTicks))
         EA.setStat("TICKDOWN", Short.toString(maxTicks));
       else if (makeLongLasting) {
         EA.makeLongLasting();
         if (!uninvocable) {
           EA.makeNonUninvokable();
           if (unrevocableSpells == null) unrevocableSpells = new Vector<Ability>();
           unrevocableSpells.add(EA);
         }
       }
     }
   }
   return true;
 }
 public String getObjName() {
   String objName;
   short val = getRequiredISOLanguageId();
   objName = Short.toString(val);
   return (objName);
 }
  private void processRequest(PDU pdu) throws DBException, IOException {
    // Process the request and add to SMS_RECEIVE_QUEUE
    if (pdu.getCommandId() == Data.DELIVER_SM) {

      dsm = (DeliverSM) pdu;
      this.userId = dsm.getSourceAddr().getAddress();
      this.serviceId = dsm.getDestAddr().getAddress();
      this.info = dsm.getShortMessage();

      ByteBuffer da = null;

      try {
        da = dsm.getDestSubaddress();

        String te = Convert.hexToString(da.getHexDump().substring(2));

        //				this.RequestID = te;
        Gateway.util.log(this.getClass().getName(), "getDestSubaddress:" + te);
      } catch (ValueNotSetException ex) {

      }
      short destport = 0;
      try {
        destport = dsm.getDestinationPort();

        Gateway.util.log(this.getClass().getName(), "getDestinationPort:" + destport);
      } catch (ValueNotSetException e) {
        // TODO Auto-generated catch block
        // Tim Dport o day
        // ByteBuffer otaData =new
        // ByteBuffer(info.getBytes(Data.ENC_ISO8859_1));
        ByteBuffer otaData = new ByteBuffer();
        otaData = dsm.getShortMessagebuff();
        try {

          byte udhlength = otaData.removeByte();
          byte udhele1 = otaData.removeByte();
          byte udhele2 = otaData.removeByte();

          short sdport = otaData.removeShort();

          short ssport = otaData.removeShort();

          String newmsg = otaData.removeString(otaData.length(), Data.ENC_ISO8859_1);

          if (udhlength == 6 && udhele1 == 5) {
            destport = sdport;
            this.info = newmsg;
            Gateway.util.log(
                this.getClass().getName(), "getDestinationPort:" + destport + "@info=" + newmsg);
          }

        } catch (NotEnoughDataInByteBufferException e1) {
          // TODO Auto-generated catch block

        }
      }

      this.Dport = Short.toString(destport);

      if (this.info == null) {
        this.info = "null";
      }
      this.userId = removePlusSign(this.userId);
      this.serviceId = rebuildServiceId(this.serviceId);
      this.operator = Preference.mobileOperator;
      // Added on 22//2003 : VinaPhone gui ban tin DeliverReport voi
      // truong esm_class != 0x4. ==> He thong xem nhu ban tin thuong
      // sai format va gui thong bao -- report -- thong bao --> LOOP./
      // To pass over this, set:

      if (dsm.getEsmClass() == 0x4 || info.startsWith("id:")) { // DeliverReport
        // (not
        // processed)!
        Gateway.util.log(this.getClass().getName(), "It can be DeliverReport (not processed)!");
        return; // not processed
      }

      // Normal message (request):
      // Neu mobile o che do tieng viet
      // --> Loai bo space (ky tu 00) giua cac ky tu
      this.info = StringTool.removeChar(this.info, '\00');

      String newserviceid = this.serviceId;

      newserviceid = newserviceid.substring(newserviceid.length() - 4);

      // DANND add
      DateFormat dateFormat = new SimpleDateFormat("MMddHHmmssSSS");
      java.util.Date date = new java.util.Date();
      String datetime = dateFormat.format(date);
      this.RequestID = Preference.prefix_requestid + datetime + threadId;

      dbTools.add2SMSReceiveQueueR(
          this.userId,
          this.serviceId,
          this.operator,
          this.commandCode,
          this.info,
          this.RequestID,
          this.Dport);
    }
  }
Example #17
0
  @Test
  public void testMaxValidator() {
    byte byteValue;
    short shortValue;
    int intValue;
    long longValue;
    float floatValue;
    double doubleValue;
    BigInteger bigIntegerValue;
    BigDecimal bigDecimalValue;

    byteValue = 2;
    assertThat(
        new MaxValidator(Byte.toString(Byte.MAX_VALUE)).validateInternal(byteValue), is(true));
    assertThat(new MaxValidator(Byte.toString(Byte.MAX_VALUE)).validate(byteValue).size(), is(0));
    assertThat(
        new MaxValidator(Byte.toString(Byte.MIN_VALUE)).validateInternal(byteValue), is(false));
    assertThat(new MaxValidator(Byte.toString(Byte.MIN_VALUE)).validate(byteValue).size(), is(1));
    assertThat(
        new MaxValidator(Byte.toString(Byte.MIN_VALUE)).validate(byteValue),
        hasItem(hasAClass(equalTo(MaxValidator.class))));

    shortValue = 3;
    assertThat(
        new MaxValidator(Short.toString(Short.MAX_VALUE)).validateInternal(shortValue), is(true));
    assertThat(
        new MaxValidator(Short.toString(Short.MAX_VALUE)).validate(shortValue).size(), is(0));
    assertThat(
        new MaxValidator(Short.toString(Short.MIN_VALUE)).validateInternal(shortValue), is(false));
    assertThat(
        new MaxValidator(Short.toString(Short.MIN_VALUE)).validate(shortValue).size(), is(1));
    assertThat(
        new MaxValidator(Short.toString(Short.MIN_VALUE)).validate(shortValue),
        hasItem(hasAClass(equalTo(MaxValidator.class))));

    intValue = 4;
    assertThat(
        new MaxValidator(Integer.toString(Integer.MAX_VALUE)).validateInternal(intValue), is(true));
    assertThat(
        new MaxValidator(Integer.toString(Integer.MAX_VALUE)).validate(intValue).size(), is(0));
    assertThat(
        new MaxValidator(Integer.toString(Integer.MIN_VALUE)).validateInternal(intValue),
        is(false));
    assertThat(
        new MaxValidator(Integer.toString(Integer.MIN_VALUE)).validate(intValue).size(), is(1));
    assertThat(
        new MaxValidator(Integer.toString(Integer.MIN_VALUE)).validate(intValue),
        hasItem(hasAClass(equalTo(MaxValidator.class))));

    longValue = 5;
    assertThat(
        new MaxValidator(Long.toString(Long.MAX_VALUE)).validateInternal(longValue), is(true));
    assertThat(new MaxValidator(Long.toString(Long.MAX_VALUE)).validate(longValue).size(), is(0));
    assertThat(
        new MaxValidator(Long.toString(Long.MIN_VALUE)).validateInternal(longValue), is(false));
    assertThat(new MaxValidator(Long.toString(Long.MIN_VALUE)).validate(longValue).size(), is(1));
    assertThat(
        new MaxValidator(Long.toString(Long.MIN_VALUE)).validate(longValue),
        hasItem(hasAClass(equalTo(MaxValidator.class))));

    floatValue = 4.7f;
    assertThat(
        new MaxValidator(Float.toString(Float.MAX_VALUE)).validateInternal(floatValue), is(true));
    assertThat(
        new MaxValidator(Float.toString(Float.MAX_VALUE)).validate(floatValue).size(), is(0));
    assertThat(
        new MaxValidator(Float.toString(Float.MIN_VALUE)).validateInternal(floatValue), is(false));
    assertThat(
        new MaxValidator(Float.toString(Float.MIN_VALUE)).validate(floatValue).size(), is(1));
    assertThat(
        new MaxValidator(Float.toString(Float.MIN_VALUE)).validate(floatValue),
        hasItem(hasAClass(equalTo(MaxValidator.class))));

    doubleValue = 7.5e10;
    assertThat(
        new MaxValidator(Double.toString(Double.MAX_VALUE)).validateInternal(doubleValue),
        is(true));
    assertThat(
        new MaxValidator(Double.toString(Double.MAX_VALUE)).validate(doubleValue).size(), is(0));
    assertThat(
        new MaxValidator(Double.toString(Double.MIN_VALUE)).validateInternal(doubleValue),
        is(false));
    assertThat(
        new MaxValidator(Double.toString(Double.MIN_VALUE)).validate(doubleValue).size(), is(1));
    assertThat(
        new MaxValidator(Double.toString(Double.MIN_VALUE)).validate(doubleValue),
        hasItem(hasAClass(equalTo(MaxValidator.class))));

    bigIntegerValue = new BigInteger(10, new Random());
    assertThat(
        new MaxValidator(new BigInteger(Long.toString(Long.MAX_VALUE)).toString(10))
            .validateInternal(bigIntegerValue),
        is(true));
    assertThat(
        new MaxValidator(new BigInteger(Long.toString(Long.MAX_VALUE)).toString(10))
            .validate(bigIntegerValue)
            .size(),
        is(0));
    assertThat(
        new MaxValidator(new BigInteger(Long.toString(Long.MIN_VALUE)).toString(10))
            .validateInternal(bigIntegerValue),
        is(false));
    assertThat(
        new MaxValidator(new BigInteger(Long.toString(Long.MIN_VALUE)).toString(10))
            .validate(bigIntegerValue)
            .size(),
        is(1));
    assertThat(
        new MaxValidator(new BigInteger(Long.toString(Long.MIN_VALUE)).toString(10))
            .validate(bigIntegerValue),
        hasItem(hasAClass(equalTo(MaxValidator.class))));

    bigDecimalValue = new BigDecimal(new BigInteger(10, new Random()), MathContext.DECIMAL64);
    assertThat(
        new MaxValidator(new BigDecimal(Double.MAX_VALUE).toString())
            .validateInternal(bigDecimalValue),
        is(true));
    assertThat(
        new MaxValidator(new BigDecimal(Double.MAX_VALUE).toString())
            .validate(bigDecimalValue)
            .size(),
        is(0));
    assertThat(
        new MaxValidator(new BigDecimal(Double.MIN_VALUE).toString())
            .validateInternal(bigDecimalValue),
        is(false));
    assertThat(
        new MaxValidator(new BigDecimal(Double.MIN_VALUE).toString())
            .validate(bigDecimalValue)
            .size(),
        is(1));
    assertThat(
        new MaxValidator(new BigDecimal(Double.MIN_VALUE).toString()).validate(bigDecimalValue),
        hasItem(hasAClass(equalTo(MaxValidator.class))));
  }