Example usage for java.lang Short Short

List of usage examples for java.lang Short Short

Introduction

In this page you can find the example usage for java.lang Short Short.

Prototype

@Deprecated(since = "9")
public Short(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Short object that represents the short value indicated by the String parameter.

Usage

From source file:hermes.providers.messages.MapMessageImpl.java

public void setShort(String arg0, short arg1) throws JMSException {
    body.put(arg0, new Short(arg1));
}

From source file:HexFormat.java

public static void main(String[] args) {
    String result;/*  w  w  w  . j av a  2 s.c  o m*/
    HexFormat format = new HexFormat();

    // byte
    byte bNumber = 0x33;
    result = format.format(bNumber);
    if (result.equals("33")) {
        System.out.print("Success => ");
    } else {
        System.out.print("FAILURE => ");
    }
    System.out.println("Byte: " + bNumber + " (0x" + result + ")");

    bNumber = (byte) 0x85;
    result = format.format(bNumber);
    if (result.equals("85")) {
        System.out.print("Success => ");
    } else {
        System.out.print("FAILURE => ");
    }
    System.out.println("Byte: " + bNumber + " (0x" + result + ")");

    bNumber = (byte) 0x0f;
    result = format.format(bNumber);
    if (result.equals("0f")) {
        System.out.print("Success => ");
    } else {
        System.out.print("FAILURE => ");
    }
    System.out.println("Byte: " + bNumber + " (0x" + result + ")");

    short sNumber = (short) 0xa2b6;
    result = format.format(sNumber);
    if (result.equals("a2b6")) {
        System.out.print("Success => ");
    } else {
        System.out.print("FAILURE => ");
    }
    System.out.println("Byte: " + bNumber + " (0x" + result + ")");

    format.setUpperCase(true);

    int iNumber = (int) 0x4321fedc;
    result = format.format(iNumber);
    if (result.equals("4321FEDC")) {
        System.out.print("Success => ");
    } else {
        System.out.print("FAILURE => ");
    }
    System.out.println("Byte: " + bNumber + " (0x" + result + ")");

    long lNumber = (long) 0x4321fedc4321fedcL;
    result = format.format(lNumber);
    if (result.equals("4321FEDC4321FEDC")) {
        System.out.print("Success => ");
    } else {
        System.out.print("FAILURE => ");
    }
    System.out.println("Byte: " + bNumber + " (0x" + result + ")");

    String num = "0xfe";
    Number number = null;
    Byte bExpect = new Byte((byte) 0xfe);
    try {
        number = format.parse(num);
    } catch (ParseException e) {
        System.out.println(e);
        e.printStackTrace();
    }
    if ((number instanceof Byte) && (number.equals(bExpect))) {
        System.out.print("Success => ");
    } else {
        System.out.print("FAILURE => ");
    }
    System.out.println("Byte: " + bExpect + " result: " + number);

    num = "0xf";
    number = null;
    bExpect = new Byte((byte) 0xf);
    try {
        number = format.parse(num);
    } catch (ParseException e) {
        System.out.println(e);
        e.printStackTrace();
    }
    if ((number instanceof Byte) && (number.equals(bExpect))) {
        System.out.print("Success => ");
    } else {
        System.out.print("FAILURE => ");
    }
    System.out.println("Byte: " + bExpect + " result: " + number);

    num = "0xf0f0";
    number = null;
    Short sExpect = new Short((short) 0xf0f0);
    try {
        number = format.parse(num);
    } catch (ParseException e) {
        System.out.println(e);
        e.printStackTrace();
    }
    if ((number instanceof Short) && (number.equals(sExpect))) {
        System.out.print("Success => ");
    } else {
        System.out.print("FAILURE => ");
    }
    System.out.println("Short: " + sExpect + " result: " + number);

    num = "0xdEAdbEEf";
    number = null;
    Integer iExpect = new Integer((int) 0xdEAdbEEf);
    try {
        number = format.parse(num);
    } catch (ParseException e) {
        System.out.println(e);
        e.printStackTrace();
    }
    if ((number instanceof Integer) && (number.equals(iExpect))) {
        System.out.print("Success => ");
    } else {
        System.out.print("FAILURE => ");
    }
    System.out.println("Integer: " + iExpect + " result: " + number);
}

From source file:com.isencia.passerelle.message.TokenHelper.java

/**
 * Tries to get a Integer Short the token, by:
 * <ul>/*from   w ww. j  av  a  2 s  .co  m*/
 * <li>checking if the token is not an ObjectToken, containing a Short
 * <li>checking if the token is not an ObjectToken, and converting the object.toString() into a Short
 * <li>checking if the token is not a StringToken, and converting the string into a Short
 * <li>checking if the token is not a ScalarToken, and reading its integer value and converting it to a short value
 * <li>checking if the token is not a ScalarToken, and reading its double value and rounding to an short value
 * </ul>
 * Remark that converting a integer to a short may lead to loss of precision and/or of most-significant bytes. The
 * result can be that a big integer value gets converted into some negative short value.
 * 
 * @param token
 * @return
 */
public static Short getShortFromToken(Token token) throws PasserelleException {
    if (logger.isTraceEnabled()) {
        logger.trace(token.toString()); // TODO Check if correct converted
    }
    Short res = null;

    if (token != null) {
        try {
            if (token instanceof ObjectToken) {
                Object obj = ((ObjectToken) token).getValue();
                if (obj instanceof Short) {
                    res = (Short) obj;
                } else if (obj != null) {
                    try {
                        res = Short.valueOf(obj.toString());
                    } catch (NumberFormatException e) {
                        throw new PasserelleException(ErrorCode.MSG_CONTENT_TYPE_ERROR,
                                "Invalid Short format in " + token, e);
                    }
                }
            } else {
                if (token instanceof StringToken) {
                    String tokenMessage = ((StringToken) token).stringValue();
                    if (tokenMessage != null) {
                        try {
                            res = Short.valueOf(tokenMessage);
                        } catch (NumberFormatException e) {
                            throw new PasserelleException(ErrorCode.MSG_CONTENT_TYPE_ERROR,
                                    "Invalid Short format in " + token, e);
                        }
                    }
                } else if (token instanceof ScalarToken) {
                    try {
                        res = new Short((short) ((ScalarToken) token).intValue());
                    } catch (IllegalActionException e) {
                        // try rounding it from a double
                        try {
                            res = new Short((short) Math.round(((ScalarToken) token).doubleValue()));
                        } catch (IllegalActionException e1) {
                            // not even doubleValue is supported...
                            throw new PasserelleException(ErrorCode.MSG_CONTENT_TYPE_ERROR,
                                    "Invalid token for obtaining Short value in " + token, e1);
                        }
                    }
                } else {
                    throw new PasserelleException(ErrorCode.MSG_CONTENT_TYPE_ERROR,
                            "Invalid token for obtaining Short value in " + token, null);
                }
            }
        } catch (Exception e) {
            throw new PasserelleException(ErrorCode.MSG_CONTENT_TYPE_ERROR,
                    "Error building Short from token in " + token, e);
        }
    }

    if (logger.isTraceEnabled()) {
        logger.trace("exit :" + res);
    }
    return res;
}

From source file:com.edmunds.autotest.AutoTestGetterSetter.java

private static Map<Class<?>, Object> createDefaultValueMap() {
    Map<Class<?>, Object> valueMap = new HashMap<Class<?>, Object>();

    valueMap.put(byte.class, new Byte((byte) 0));
    valueMap.put(short.class, new Short((short) 0));
    valueMap.put(int.class, new Integer(0));
    valueMap.put(long.class, new Long(0));
    valueMap.put(float.class, new Float(0));
    valueMap.put(double.class, new Double(0));
    valueMap.put(boolean.class, Boolean.FALSE);
    valueMap.put(char.class, new Character((char) 0));

    valueMap.put(Byte.class, new Byte((byte) 0));
    valueMap.put(Short.class, new Short((short) 0));
    valueMap.put(Integer.class, new Integer(0));
    valueMap.put(Long.class, new Long(0));
    valueMap.put(Float.class, new Float(0));
    valueMap.put(Double.class, new Double(0));
    valueMap.put(Boolean.class, Boolean.FALSE);
    valueMap.put(Character.class, new Character((char) 0));

    return valueMap;
}

From source file:com.jaspersoft.studio.editor.preview.input.BigNumericInput.java

protected Number getNumber(String number) throws NumberFormatException {
    if (param.getValueClass().equals(Long.class)) {
        return new Long(number);
    } else if (param.getValueClass().equals(BigInteger.class)) {
        return new BigInteger(number);
    } else if (param.getValueClass().equals(Float.class)) {
        return new Float(number);
    } else if (param.getValueClass().equals(Double.class)) {
        return new Double(number);
    } else if (param.getValueClass().equals(Integer.class)) {
        return new Integer(number);
    } else if (param.getValueClass().equals(Short.class)) {
        return new Short(number);
    } else if (param.getValueClass().equals(Byte.class)) {
        return new Byte(number);
    } else if (param.getValueClass().equals(BigDecimal.class)) {
        return new BigDecimal(number);
    }/*from   w w w  . j a va2s.  c  o  m*/
    return null;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskXMsgRspnHandler.CFAsteriskXMsgRspnISOLanguageLockedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from  ww  w.j av  a2s .  c o m*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // ISOLanguage Attributes
        String attrISOCode = null;
        String attrBaseLanguageCode = null;
        String attrISOCountryId = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnISOLanguageLocked");

        CFAsteriskXMsgRspnHandler xmsgRspnHandler = (CFAsteriskXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFAsteriskSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOCode")) {
                if (attrISOCode != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOCode = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("BaseLanguageCode")) {
                if (attrBaseLanguageCode != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrBaseLanguageCode = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOCountryId")) {
                if (attrISOCountryId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOCountryId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrId == null) || (attrId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Id");
        }
        if (attrISOCode == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ISOCode");
        }
        if (attrBaseLanguageCode == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "BaseLanguageCode");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        short natId = Short.parseShort(attrId);

        String natISOCode = attrISOCode;

        String natBaseLanguageCode = attrBaseLanguageCode;

        Short natISOCountryId;
        if ((attrISOCountryId == null) || (attrISOCountryId.length() <= 0)) {
            natISOCountryId = null;
        } else {
            natISOCountryId = new Short(Short.parseShort(attrISOCountryId));
        }

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Instantiate a buffer for the parsed information
        ICFAsteriskISOLanguageObj obj = (ICFAsteriskISOLanguageObj) schemaObj.getISOLanguageTableObj()
                .newInstance();
        CFSecurityISOLanguageBuff dataBuff = obj.getISOLanguageBuff();
        dataBuff.setRequiredId(natId);
        dataBuff.setRequiredISOCode(natISOCode);
        dataBuff.setRequiredBaseLanguageCode(natBaseLanguageCode);
        dataBuff.setOptionalISOCountryId(natISOCountryId);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        ICFAsteriskISOLanguageObj realized = (ICFAsteriskISOLanguageObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:com.germinus.easyconf.taglib.PropertyTag.java

private Object readProperty(ComponentProperties conf) throws JspException {
    Object value;//from   w w w .ja v a  2 s. c o m
    if (getType().equals("java.util.List")) {
        value = conf.getList(property, getPropertyFilter(), EMPTY_LIST);
    } else if (getType().equals("java.lang.Integer")) {
        value = conf.getInteger(property, getPropertyFilter(), new Integer(0));
    } else if (getType().equals("java.lang.String[]")) {
        value = conf.getStringArray(property, getPropertyFilter(), new String[0]);
    } else if (getType().equals("java.lang.String")) {
        if (defaultValue != null) {
            value = conf.getString(property, getPropertyFilter(), defaultValue);
        } else {
            value = conf.getString(property, getPropertyFilter());
        }
    } else if (getType().equals("java.lang.Double")) {
        value = new Double(conf.getDouble(property, getPropertyFilter()));
    } else if (getType().equals("java.lang.Float")) {
        value = new Float(conf.getFloat(property, getPropertyFilter()));
    } else if (getType().equals("java.lang.Byte")) {
        value = new Byte(conf.getByte(property, getPropertyFilter()));
    } else if (getType().equals("java.math.BigDecimal")) {
        value = conf.getBigDecimal(property, getPropertyFilter());
    } else if (getType().equals("java.lang.BigInteger")) {
        value = conf.getBigInteger(property, getPropertyFilter());
    } else if (getType().equals("java.lang.Boolean")) {
        value = new Boolean(conf.getBoolean(property, getPropertyFilter()));
    } else if (getType().equals("java.lang.Short")) {
        value = new Short(conf.getShort(property, getPropertyFilter()));
    } else if (getType().equals("java.lang.Long")) {
        value = new Long(conf.getLong(property, getPropertyFilter()));
    } else {
        JspException e = new JspException("Unsupported type: " + type);
        RequestUtils.saveException(pageContext, e);
        throw e;
    }
    return value;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskXMsgRspnHandler.CFAsteriskXMsgRspnISOLanguageCreatedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//  ww  w.j  ava  2  s. co  m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // ISOLanguage Attributes
        String attrISOCode = null;
        String attrBaseLanguageCode = null;
        String attrISOCountryId = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnISOLanguageCreated");

        CFAsteriskXMsgRspnHandler xmsgRspnHandler = (CFAsteriskXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFAsteriskSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOCode")) {
                if (attrISOCode != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOCode = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("BaseLanguageCode")) {
                if (attrBaseLanguageCode != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrBaseLanguageCode = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOCountryId")) {
                if (attrISOCountryId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOCountryId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrId == null) || (attrId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Id");
        }
        if (attrISOCode == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ISOCode");
        }
        if (attrBaseLanguageCode == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "BaseLanguageCode");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        short natId = Short.parseShort(attrId);

        String natISOCode = attrISOCode;

        String natBaseLanguageCode = attrBaseLanguageCode;

        Short natISOCountryId;
        if ((attrISOCountryId == null) || (attrISOCountryId.length() <= 0)) {
            natISOCountryId = null;
        } else {
            natISOCountryId = new Short(Short.parseShort(attrISOCountryId));
        }

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Instantiate a buffer for the parsed information
        ICFAsteriskISOLanguageObj obj = (ICFAsteriskISOLanguageObj) schemaObj.getISOLanguageTableObj()
                .newInstance();
        CFSecurityISOLanguageBuff dataBuff = obj.getISOLanguageBuff();
        dataBuff.setRequiredId(natId);
        dataBuff.setRequiredISOCode(natISOCode);
        dataBuff.setRequiredBaseLanguageCode(natBaseLanguageCode);
        dataBuff.setOptionalISOCountryId(natISOCountryId);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        ICFAsteriskISOLanguageObj realized = (ICFAsteriskISOLanguageObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskXMsgRspnHandler.CFAsteriskXMsgRspnISOLanguageUpdatedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//w  w  w. j a  v  a 2s.c  o m
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // ISOLanguage Attributes
        String attrISOCode = null;
        String attrBaseLanguageCode = null;
        String attrISOCountryId = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnISOLanguageUpdated");

        CFAsteriskXMsgRspnHandler xmsgRspnHandler = (CFAsteriskXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFAsteriskSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOCode")) {
                if (attrISOCode != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOCode = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("BaseLanguageCode")) {
                if (attrBaseLanguageCode != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrBaseLanguageCode = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOCountryId")) {
                if (attrISOCountryId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOCountryId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrId == null) || (attrId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Id");
        }
        if (attrISOCode == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ISOCode");
        }
        if (attrBaseLanguageCode == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "BaseLanguageCode");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        short natId = Short.parseShort(attrId);

        String natISOCode = attrISOCode;

        String natBaseLanguageCode = attrBaseLanguageCode;

        Short natISOCountryId;
        if ((attrISOCountryId == null) || (attrISOCountryId.length() <= 0)) {
            natISOCountryId = null;
        } else {
            natISOCountryId = new Short(Short.parseShort(attrISOCountryId));
        }

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Instantiate a buffer for the parsed information
        ICFAsteriskISOLanguageObj obj = (ICFAsteriskISOLanguageObj) schemaObj.getISOLanguageTableObj()
                .newInstance();
        CFSecurityISOLanguageBuff dataBuff = obj.getISOLanguageBuff();
        dataBuff.setRequiredId(natId);
        dataBuff.setRequiredISOCode(natISOCode);
        dataBuff.setRequiredBaseLanguageCode(natBaseLanguageCode);
        dataBuff.setOptionalISOCountryId(natISOCountryId);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        ICFAsteriskISOLanguageObj realized = (ICFAsteriskISOLanguageObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}

From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_4.CFFreeSwitchXMsgRspnHandler.CFFreeSwitchXMsgRspnISOLanguageUpdatedHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from www.ja  v  a 2 s  .com*/
        // Common XML Attributes
        String attrId = null;
        String attrRevision = null;
        // ISOLanguage Attributes
        String attrISOCode = null;
        String attrBaseLanguageCode = null;
        String attrISOCountryId = null;
        String attrCreatedAt = null;
        String attrCreatedBy = null;
        String attrUpdatedAt = null;
        String attrUpdatedBy = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RspnISOLanguageUpdated");

        CFFreeSwitchXMsgRspnHandler xmsgRspnHandler = (CFFreeSwitchXMsgRspnHandler) getParser();
        if (xmsgRspnHandler == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser()");
        }

        ICFFreeSwitchSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
        if (schemaObj == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "getParser().getSchemaObj()");
        }

        // Extract Attributes
        numAttrs = attrs.getLength();
        for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
            attrLocalName = attrs.getLocalName(idxAttr);
            if (attrLocalName.equals("Id")) {
                if (attrId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("Revision")) {
                if (attrRevision != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrRevision = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedAt")) {
                if (attrCreatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("CreatedBy")) {
                if (attrCreatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCreatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedAt")) {
                if (attrUpdatedAt != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedAt = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("UpdatedBy")) {
                if (attrUpdatedBy != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrUpdatedBy = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOCode")) {
                if (attrISOCode != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOCode = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("BaseLanguageCode")) {
                if (attrBaseLanguageCode != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrBaseLanguageCode = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("ISOCountryId")) {
                if (attrISOCountryId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrISOCountryId = attrs.getValue(idxAttr);
            } else if (attrLocalName.equals("schemaLocation")) {
                // ignored
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(),
                        S_ProcName, getParser().getLocationInfo(), attrLocalName);
            }
        }

        // Ensure that required attributes have values
        if ((attrId == null) || (attrId.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "Id");
        }
        if (attrISOCode == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "ISOCode");
        }
        if (attrBaseLanguageCode == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "BaseLanguageCode");
        }
        if ((attrRevision == null) || (attrRevision.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "Revision");
        }

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();

        // Convert string attributes to native Java types

        short natId = Short.parseShort(attrId);

        String natISOCode = attrISOCode;

        String natBaseLanguageCode = attrBaseLanguageCode;

        Short natISOCountryId;
        if ((attrISOCountryId == null) || (attrISOCountryId.length() <= 0)) {
            natISOCountryId = null;
        } else {
            natISOCountryId = new Short(Short.parseShort(attrISOCountryId));
        }

        int natRevision = Integer.parseInt(attrRevision);
        UUID createdBy = null;
        if (attrCreatedBy != null) {
            createdBy = UUID.fromString(attrCreatedBy);
        }
        Calendar createdAt = null;
        if (attrCreatedAt != null) {
            createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
        }
        UUID updatedBy = null;
        if (attrUpdatedBy != null) {
            updatedBy = UUID.fromString(attrUpdatedBy);
        }
        Calendar updatedAt = null;
        if (attrUpdatedAt != null) {
            updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
        }
        // Instantiate a buffer for the parsed information
        ICFFreeSwitchISOLanguageObj obj = (ICFFreeSwitchISOLanguageObj) schemaObj.getISOLanguageTableObj()
                .newInstance();
        CFSecurityISOLanguageBuff dataBuff = obj.getISOLanguageBuff();
        dataBuff.setRequiredId(natId);
        dataBuff.setRequiredISOCode(natISOCode);
        dataBuff.setRequiredBaseLanguageCode(natBaseLanguageCode);
        dataBuff.setOptionalISOCountryId(natISOCountryId);
        dataBuff.setRequiredRevision(natRevision);
        if (createdBy != null) {
            dataBuff.setCreatedByUserId(createdBy);
        }
        if (createdAt != null) {
            dataBuff.setCreatedAt(createdAt);
        }
        if (updatedBy != null) {
            dataBuff.setUpdatedByUserId(updatedBy);
        }
        if (updatedAt != null) {
            dataBuff.setUpdatedAt(updatedAt);
        }
        obj.copyBuffToPKey();
        ICFFreeSwitchISOLanguageObj realized = (ICFFreeSwitchISOLanguageObj) obj.realize();
        xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
        throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    } catch (Error e) {
        throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew "
                + e.getClass().getName() + " - " + e.getMessage(), e);
    }
}