Example usage for java.lang Short parseShort

List of usage examples for java.lang Short parseShort

Introduction

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

Prototype

public static short parseShort(String s) throws NumberFormatException 

Source Link

Document

Parses the string argument as a signed decimal short .

Usage

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmXMsgRqstHandler.CFCrmXMsgRqstISOLanguageLockHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from  w  w  w .  ja v  a  2s  .  c  o  m
        // Common XML Attributes
        String attrId = null;
        // Primary Key Attributes for Constant Enum support
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RqstISOLanguageLock");

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

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

        // Instantiate a PKey buffer for the parsed information
        CFCrmISOLanguagePKey pkey = schemaObj.getBackingStore().getFactoryISOLanguage().newPKey();

        // 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("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");
        }

        // Get current context
        CFLibXmlCoreContext curContext = getParser().getCurContext();
        // Convert string attributes to native Java types
        // and apply the converted attributes to the editBuff.

        short natId;
        natId = Short.parseShort(attrId);
        pkey.setRequiredId(natId);

        pkey.setRequiredId(natId);
        // Lock the object
        ICFCrmISOLanguageObj locked = schemaObj.getISOLanguageTableObj().lockISOLanguage(pkey);
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgISOLanguageMessageFormatter.formatISOLanguageRspnLocked("\n\t\t\t",
                        locked.getISOLanguageBuff())
                + "\n" + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response);
    } catch (RuntimeException e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmXMsgRqstHandler.CFCrmXMsgRqstISOCurrencyLockHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from  ww w  . ja v a2s  .  co  m
        // Common XML Attributes
        String attrId = null;
        // Primary Key Attributes for Constant Enum support
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RqstISOCurrencyLock");

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

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

        // Instantiate a PKey buffer for the parsed information
        CFCrmISOCurrencyPKey pkey = schemaObj.getBackingStore().getFactoryISOCurrency().newPKey();

        // 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("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");
        }

        // Get current context
        CFLibXmlCoreContext curContext = getParser().getCurContext();
        // Convert string attributes to native Java types
        // and apply the converted attributes to the editBuff.

        short natId;
        natId = Short.parseShort(attrId);
        pkey.setRequiredId(natId);

        pkey.setRequiredId(natId);
        // Lock the object
        ICFCrmISOCurrencyObj locked = schemaObj.getISOCurrencyTableObj().lockISOCurrency(pkey);
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgISOCurrencyMessageFormatter.formatISOCurrencyRspnLocked("\n\t\t\t",
                        locked.getISOCurrencyBuff())
                + "\n" + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response);
    } catch (RuntimeException e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmXMsgRqstHandler.CFCrmXMsgRqstISOCurrencyReadHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from  ww w  .  j ava  2 s . com
        // Common XML Attributes
        String attrId = null;
        // Primary Key Attributes for Constant Enum support
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RqstISOCurrencyRead");

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

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

        // Instantiate a PKey buffer for the parsed information
        CFCrmISOCurrencyPKey pkey = schemaObj.getBackingStore().getFactoryISOCurrency().newPKey();

        // 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("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");
        }

        // Get current context
        CFLibXmlCoreContext curContext = getParser().getCurContext();
        // Convert string attributes to native Java types
        // and apply the converted attributes to the editBuff.

        short natId;
        natId = Short.parseShort(attrId);
        pkey.setRequiredId(natId);

        pkey.setRequiredId(natId);
        // Read the object and prepare the XML response
        ICFCrmISOCurrencyObj read = schemaObj.getISOCurrencyTableObj().readISOCurrency(pkey, true);
        if (read != null) {
            String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                    + CFCrmXMsgISOCurrencyMessageFormatter.formatISOCurrencyRspnSingleOpenTag()
                    + CFCrmXMsgISOCurrencyMessageFormatter.formatISOCurrencyRspnDerivedRec("\n\t\t",
                            read.getISOCurrencyBuff())
                    + "\n" + "\t" + CFCrmXMsgISOCurrencyMessageFormatter.formatISOCurrencyRspnSingleCloseTag()
                    + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
            xmsgRqstHandler.appendResponse(response);
        } else {
            String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                    + CFCrmXMsgSchemaMessageFormatter.formatRspnNoDataFound() + "\n"
                    + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
            xmsgRqstHandler.appendResponse(response);
        }
    } catch (RuntimeException e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    }
}

From source file:edu.umn.msi.tropix.proteomics.parameters.ParameterUtils.java

/**
 * Uses reflection to dynamically set a parameter bean's parameters from a given map of Strings.
 * //  w w w  . j a v a  2  s .c  om
 * @param parameterMap
 *          Mapping of parameter names (attributes) to values.
 * @param parameterObject
 *          Java bean to set parameter values of of. Setter methods must conform to the Java bean naming scheme and must take in one argument of
 *          type String, Integer, Long, Float, or Double.
 * @exception IllegalArgumentException
 *              Thrown if a given setter method cannot be found or if the setter method does not conform to the rules described.
 */
@SuppressWarnings("unchecked")
public static void setParametersFromMap(final Map parameterMap, final Object parameterObject) {
    final Method[] methods = parameterObject.getClass().getMethods();
    final Map<String, Method> objectSetMethodMap = new HashMap<String, Method>(methods.length);

    for (final Method method : parameterObject.getClass().getMethods()) {
        final String methodName = method.getName();
        if (methodName.contains("set")) {
            objectSetMethodMap.put(method.getName(), method);
        }
    }

    for (final Object keyObject : parameterMap.keySet()) {
        final String key = (String) keyObject;
        final String value = (String) parameterMap.get(key);
        final String setterMethodName = "set" + key.substring(0, 1).toUpperCase() + key.substring(1);
        final Method setterMethod = objectSetMethodMap.get(setterMethodName);
        if (setterMethod == null) {
            continue;
        }
        final Class<?>[] parameterTypes = setterMethod.getParameterTypes();
        if (parameterTypes.length != 1) {
            throw new IllegalArgumentException(
                    "Illegal setter method found, must take in exactly one argument.");
        }
        final Class<?> argumentType = parameterTypes[0];
        try {
            if (argumentType.equals(String.class)) {
                setterMethod.invoke(parameterObject, value);
                continue;
            }
            if (value == null || value.trim().equals("")) {
                setterMethod.invoke(parameterObject, (Object) null);
                continue;
            }
            if (argumentType.equals(Double.class) || argumentType.equals(double.class)) {
                setterMethod.invoke(parameterObject, Double.parseDouble(value));
            } else if (argumentType.equals(Integer.class) || argumentType.equals(int.class)) {
                setterMethod.invoke(parameterObject, Integer.parseInt(value));
            } else if (argumentType.equals(Long.class) || argumentType.equals(long.class)) {
                setterMethod.invoke(parameterObject, Long.parseLong(value));
            } else if (argumentType.equals(Float.class) || argumentType.equals(float.class)) {
                setterMethod.invoke(parameterObject, Float.parseFloat(value));
            } else if (argumentType.equals(Boolean.class) || argumentType.equals(boolean.class)) {
                setterMethod.invoke(parameterObject, Boolean.parseBoolean(value));
            } else if (argumentType.equals(Short.class) || argumentType.equals(short.class)) {
                setterMethod.invoke(parameterObject, Short.parseShort(value));
            } else {
                throw new IllegalArgumentException("Illegal type found for argument to setter bean - type is "
                        + argumentType + " - key is " + key);
            }
        } catch (final Exception e) {
            throw new IllegalArgumentException(e);
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmXMsgRqstHandler.CFCrmXMsgRqstISOLanguageDeleteByCountryIdxHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from   w ww  .  j ava  2s  .c om*/
        // Common XML Attributes
        String attrId = null;
        String attrISOCountryId = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RqstISOLanguageDeleteByCountryIdx");

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

        ICFCrmSchemaObj schemaObj = xmsgRqstHandler.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("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

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();
        // Convert string attributes to native Java types

        Short natISOCountryId;
        natISOCountryId = new Short(Short.parseShort(attrISOCountryId));

        // Delete the objects
        schemaObj.getISOLanguageTableObj().deleteISOLanguageByCountryIdx(natISOCountryId);
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgISOLanguageMessageFormatter.formatISOLanguageRspnDeleted() + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response);
    } catch (RuntimeException e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmXMsgRqstHandler.CFCrmXMsgRqstAddressDeleteByCountryIdxHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*w ww .j a v  a  2  s .c o m*/
        // Common XML Attributes
        String attrId = null;
        String attrCountryId = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RqstAddressDeleteByCountryIdx");

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

        ICFCrmSchemaObj schemaObj = xmsgRqstHandler.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("CountryId")) {
                if (attrCountryId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrCountryId = 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$implRqstTableDeleteByHandlerCheckReqKeyAttrs$

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();
        // Convert string attributes to native Java types

        Short natCountryId;
        natCountryId = new Short(Short.parseShort(attrCountryId));

        // Delete the objects
        schemaObj.getAddressTableObj().deleteAddressByCountryIdx(natCountryId);
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgAddressMessageFormatter.formatAddressRspnDeleted() + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response);
    } catch (RuntimeException e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    }
}

From source file:com.termmed.reconciliation.test.GroupNumberReconciliationTest.java

/**
 * Load output inferred relationship.// w w w . ja  v  a  2s.c o  m
 *
 * @param relationshipFiles the relationship files
 * @param rels the rels
 * @param i the i
 * @throws IOException Signals that an I/O exception has occurred.
 */
public void loadOutputInferredRelationship(String[] relationshipFiles, ArrayList<Relationship> rels, int i)
        throws IOException {

    String line;
    String[] spl;

    long c1;
    long c2;
    int rg;
    long ty;
    int et;
    long mo;
    short ac;
    long ch = Long.parseLong(I_Constants.INFERRED);

    for (String relFile : relationshipFiles) {
        FileInputStream rfis = new FileInputStream(relFile);
        InputStreamReader risr = new InputStreamReader(rfis, "UTF-8");
        BufferedReader rbr = new BufferedReader(risr);
        rbr.readLine();

        while ((line = rbr.readLine()) != null) {

            spl = line.split("\t", -1);
            if (spl[2].equals("1") && spl[8].equals(I_Constants.INFERRED)) {
                c1 = Long.parseLong(spl[4]);
                c2 = Long.parseLong(spl[5]);
                rg = Integer.parseInt(spl[6]);
                ty = Long.parseLong(spl[7]);
                et = Integer.parseInt(spl[1]);
                mo = Long.parseLong(spl[3]);
                ac = Short.parseShort(spl[2]);
                String rid;
                if (i == 0) {
                    rid = "";
                } else {
                    rid = spl[0];
                }
                Relationship rel = new Relationship(c1, c2, ty, rg, rid, et, mo, ac, ch);
                rels.add(rel);
            }
        }
        rbr.close();
        rbr = null;
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmXMsgRqstHandler.CFCrmXMsgRqstURLProtocolDeleteByIdIdxHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {/*from   www.  jav a  2s. c  o  m*/
        // Common XML Attributes
        String attrId = null;
        String attrURLProtocolId = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RqstURLProtocolDeleteByIdIdx");

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

        ICFCrmSchemaObj schemaObj = xmsgRqstHandler.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("URLProtocolId")) {
                if (attrURLProtocolId != null) {
                    throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                            S_ProcName, S_LocalName, attrLocalName);
                }
                attrURLProtocolId = 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$implRqstTableDeleteByHandlerCheckReqKeyAttrs$

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();
        // Convert string attributes to native Java types

        short natURLProtocolId;
        natURLProtocolId = Short.parseShort(attrURLProtocolId);

        // Delete the objects
        schemaObj.getURLProtocolTableObj().deleteURLProtocolByIdIdx(natURLProtocolId);
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgURLProtocolMessageFormatter.formatURLProtocolRspnDeleted() + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response);
    } catch (RuntimeException e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmXMsgRqstHandler.CFCrmXMsgRqstISOLanguageDeleteByCountryIdxHandler.java

public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
    try {//from w  ww. ja v  a 2  s  .  c o m
        // Common XML Attributes
        String attrId = null;
        String attrISOCountryId = null;
        // Attribute Extraction
        String attrLocalName;
        int numAttrs;
        int idxAttr;
        final String S_ProcName = "startElement";
        final String S_LocalName = "LocalName";

        assert qName.equals("RqstISOLanguageDeleteByCountryIdx");

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

        ICFCrmSchemaObj schemaObj = xmsgRqstHandler.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("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$implRqstTableDeleteByHandlerCheckReqKeyAttrs$

        // Save named attributes to context
        CFLibXmlCoreContext curContext = getParser().getCurContext();
        // Convert string attributes to native Java types

        Short natISOCountryId;
        natISOCountryId = new Short(Short.parseShort(attrISOCountryId));

        // Delete the objects
        schemaObj.getISOLanguageTableObj().deleteISOLanguageByCountryIdx(natISOCountryId);
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgISOLanguageMessageFormatter.formatISOLanguageRspnDeleted() + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        ((CFCrmXMsgRqstHandler) getParser()).appendResponse(response);
    } catch (RuntimeException e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
        String response = CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPreamble() + "\n" + "\t"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n"
                + CFCrmXMsgSchemaMessageFormatter.formatRspnXmlPostamble();
        CFCrmXMsgRqstHandler xmsgRqstHandler = ((CFCrmXMsgRqstHandler) getParser());
        xmsgRqstHandler.resetResponse();
        xmsgRqstHandler.appendResponse(response);
        xmsgRqstHandler.setCaughtException(true);
    }
}

From source file:com.example.forum.TypeUtils.java

/**
 * short^?B//from   www.j  a  v a2s.c  o m
 * @param shortString ??B
 * @param defaultValue ftHgl?B
 * @return short^l?B
 */
public static short toShort(String shortString, short defaultValue) {
    if (shortString == null || shortString.length() == 0) {
        return defaultValue;
    }

    short shortValue = defaultValue;
    try {
        shortValue = Short.parseShort(shortString);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
    return shortValue;
}