Example usage for java.lang Short valueOf

List of usage examples for java.lang Short valueOf

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static Short valueOf(short s) 

Source Link

Document

Returns a Short instance representing the specified short value.

Usage

From source file:hydrograph.ui.dataviewer.filter.FilterValidator.java

private boolean validate(String type, String value, DebugDataViewer debugDataViewer, String fieldName)
        throws ParseException {
    if (FilterConstants.TYPE_BOOLEAN.equals(type)) {
        Boolean convertedBoolean = Boolean.valueOf(value);
        if (!StringUtils.equalsIgnoreCase(convertedBoolean.toString(), value)) {
            return false;
        }//from   w ww .  jav a  2s . co  m
    } else if (FilterConstants.TYPE_DOUBLE.equals(type)) {
        Double.valueOf(value);
    } else if (FilterConstants.TYPE_FLOAT.equals(type)) {
        Float.valueOf(value);
    } else if (FilterConstants.TYPE_INTEGER.equals(type)) {
        Integer.valueOf(value);
    } else if (FilterConstants.TYPE_LONG.equals(type)) {
        Long.valueOf(value);
    } else if (FilterConstants.TYPE_SHORT.equals(type)) {
        Short.valueOf(value);
    } else if (FilterConstants.TYPE_STRING.equals(type)) {
        String.valueOf(value);
    } else if (FilterConstants.TYPE_BIGDECIMAL.equals(type)) {
        new BigDecimal(value);
    } else if (FilterConstants.TYPE_DATE.equals(type)) {
        String debugFileName = debugDataViewer.getDebugFileName();
        String debugFileLocation = debugDataViewer.getDebugFileLocation();
        Fields dataViewerFileSchema = ViewDataSchemaHelper.INSTANCE.getFieldsFromSchema(
                debugFileLocation + debugFileName + AdapterConstants.SCHEMA_FILE_EXTENTION);
        for (Field field : dataViewerFileSchema.getField()) {
            if (field.getName().equalsIgnoreCase(fieldName)) {
                SimpleDateFormat sdf = new SimpleDateFormat(field.getFormat());
                sdf.parse(value);
            }
        }

    }
    return true;

}

From source file:org.mifos.accounts.persistence.AccountPersistence.java

public List<AccountStateEntity> retrieveAllActiveAccountStateList(Short prdTypeId) throws PersistenceException {
    HashMap<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("prdTypeId", prdTypeId);
    queryParameters.put("OPTIONAL_FLAG", Short.valueOf("1"));
    List<AccountStateEntity> queryResult = executeNamedQuery(NamedQueryConstants.RETRIEVEALLACTIVEACCOUNTSTATES,
            queryParameters);// w  w  w .ja v  a 2  s. c om
    initializeAccountStates(queryResult);
    return queryResult;
}

From source file:org.grouplens.grapht.BindingImpl.java

private Object coerce(Object in) {
    Class<?> boxedSource = Types.box(sourceType);
    if (Integer.class.equals(boxedSource)) {
        // normalize to BigInteger and then cast to int
        return Integer.valueOf(toBigInteger(in).intValue());
    } else if (Short.class.equals(boxedSource)) {
        // normalize to BigInteger and then cast to short
        return Short.valueOf(toBigInteger(in).shortValue());
    } else if (Byte.class.equals(boxedSource)) {
        // normalize to BigInteger and then cast to byte
        return Byte.valueOf(toBigInteger(in).byteValue());
    } else if (Long.class.equals(boxedSource)) {
        // normalize to BigInteger and then cast to long
        return Long.valueOf(toBigInteger(in).longValue());
    } else if (Float.class.equals(boxedSource)) {
        // normalize to BigDecimal and then cast to float
        return Float.valueOf(toBigDecimal(in).floatValue());
    } else if (Double.class.equals(boxedSource)) {
        // normalize to BigDecimal and then cast to double
        return Double.valueOf(toBigDecimal(in).doubleValue());
    } else if (BigDecimal.class.equals(boxedSource)) {
        // normalize to BigDecimal
        return toBigDecimal(in);
    } else if (BigInteger.class.equals(boxedSource)) {
        // normalize to BigInteger
        return toBigInteger(in);
    } else {/*from   w  w  w .  jav a2  s  . c  om*/
        // don't perform any type coercion
        return in;
    }
}

From source file:com.ebay.nest.io.sede.RegexSerDe.java

@Override
public Object deserialize(Writable blob) throws SerDeException {

    Text rowText = (Text) blob;
    Matcher m = inputPattern.matcher(rowText.toString());

    if (m.groupCount() != numColumns) {
        throw new SerDeException("Number of matching groups doesn't match the number of columns");
    }/*from   w w w.  j  a v a2 s  .c  om*/

    // If do not match, ignore the line, return a row with all nulls.
    if (!m.matches()) {
        unmatchedRowsCount++;
        if (!alreadyLoggedNoMatch) {
            // Report the row if its the first time
            LOG.warn("" + unmatchedRowsCount + " unmatched rows are found: " + rowText);
            alreadyLoggedNoMatch = true;
        }
        return null;
    }

    // Otherwise, return the row.
    for (int c = 0; c < numColumns; c++) {
        try {
            String t = m.group(c + 1);
            TypeInfo typeInfo = columnTypes.get(c);
            String typeName = typeInfo.getTypeName();

            // Convert the column to the correct type when needed and set in row obj
            if (typeName.equals(serdeConstants.STRING_TYPE_NAME)) {
                row.set(c, t);
            } else if (typeName.equals(serdeConstants.TINYINT_TYPE_NAME)) {
                Byte b;
                b = Byte.valueOf(t);
                row.set(c, b);
            } else if (typeName.equals(serdeConstants.SMALLINT_TYPE_NAME)) {
                Short s;
                s = Short.valueOf(t);
                row.set(c, s);
            } else if (typeName.equals(serdeConstants.INT_TYPE_NAME)) {
                Integer i;
                i = Integer.valueOf(t);
                row.set(c, i);
            } else if (typeName.equals(serdeConstants.BIGINT_TYPE_NAME)) {
                Long l;
                l = Long.valueOf(t);
                row.set(c, l);
            } else if (typeName.equals(serdeConstants.FLOAT_TYPE_NAME)) {
                Float f;
                f = Float.valueOf(t);
                row.set(c, f);
            } else if (typeName.equals(serdeConstants.DOUBLE_TYPE_NAME)) {
                Double d;
                d = Double.valueOf(t);
                row.set(c, d);
            } else if (typeName.equals(serdeConstants.BOOLEAN_TYPE_NAME)) {
                Boolean b;
                b = Boolean.valueOf(t);
                row.set(c, b);
            } else if (typeName.equals(serdeConstants.TIMESTAMP_TYPE_NAME)) {
                Timestamp ts;
                ts = Timestamp.valueOf(t);
                row.set(c, ts);
            } else if (typeName.equals(serdeConstants.DATE_TYPE_NAME)) {
                Date d;
                d = Date.valueOf(t);
                row.set(c, d);
            } else if (typeName.equals(serdeConstants.DECIMAL_TYPE_NAME)) {
                HiveDecimal bd;
                bd = new HiveDecimal(t);
                row.set(c, bd);
            } else if (typeInfo instanceof PrimitiveTypeInfo
                    && ((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory() == PrimitiveCategory.VARCHAR) {
                VarcharTypeParams varcharParams = (VarcharTypeParams) ParameterizedPrimitiveTypeUtils
                        .getTypeParamsFromTypeInfo(typeInfo);
                HiveVarchar hv = new HiveVarchar(t, varcharParams != null ? varcharParams.length : -1);
                row.set(c, hv);
            }
        } catch (RuntimeException e) {
            partialMatchedRowsCount++;
            if (!alreadyLoggedPartialMatch) {
                // Report the row if its the first row
                LOG.warn("" + partialMatchedRowsCount + " partially unmatched rows are found, "
                        + " cannot find group " + c + ": " + rowText);
                alreadyLoggedPartialMatch = true;
            }
            row.set(c, null);
        }
    }
    return row;
}

From source file:cn.clickvalue.cv2.model.rowmapper.BeanPropertyRowMapper.java

/**
 * Retrieve a JDBC column value from a ResultSet, using the specified value type.
 * <p>Uses the specifically typed ResultSet accessor methods, falling back to
 * {@link #getResultSetValue(java.sql.ResultSet, int)} for unknown types.
 * <p>Note that the returned value may not be assignable to the specified
 * required type, in case of an unknown type. Calling code needs to deal
 * with this case appropriately, e.g. throwing a corresponding exception.
 * @param rs is the ResultSet holding the data
 * @param index is the column index/*from  w  ww  .j  a v  a  2s  .  c  o  m*/
 * @param requiredType the required value type (may be <code>null</code>)
 * @return the value object
 * @throws SQLException if thrown by the JDBC API
 */
public static Object getResultSetValue(ResultSet rs, int index, Class requiredType) throws SQLException {
    if (requiredType == null) {
        return getResultSetValue(rs, index);
    }

    Object value = null;
    boolean wasNullCheck = false;

    // Explicitly extract typed value, as far as possible.
    if (String.class.equals(requiredType)) {
        value = rs.getString(index);
    } else if (boolean.class.equals(requiredType) || Boolean.class.equals(requiredType)) {
        value = Boolean.valueOf(rs.getBoolean(index));
        wasNullCheck = true;
    } else if (byte.class.equals(requiredType) || Byte.class.equals(requiredType)) {
        value = Byte.valueOf(rs.getByte(index));
        wasNullCheck = true;
    } else if (short.class.equals(requiredType) || Short.class.equals(requiredType)) {
        value = Short.valueOf(rs.getShort(index));
        wasNullCheck = true;
    } else if (int.class.equals(requiredType) || Integer.class.equals(requiredType)) {
        value = Integer.valueOf(rs.getInt(index));
        wasNullCheck = true;
    } else if (long.class.equals(requiredType) || Long.class.equals(requiredType)) {
        value = Long.valueOf(rs.getLong(index));
        wasNullCheck = true;
    } else if (float.class.equals(requiredType) || Float.class.equals(requiredType)) {
        value = Float.valueOf(rs.getFloat(index));
        wasNullCheck = true;
    } else if (double.class.equals(requiredType) || Double.class.equals(requiredType)
            || Number.class.equals(requiredType)) {
        value = Double.valueOf(rs.getDouble(index));
        wasNullCheck = true;
    } else if (byte[].class.equals(requiredType)) {
        value = rs.getBytes(index);
    } else if (java.sql.Date.class.equals(requiredType)) {
        value = rs.getDate(index);
    } else if (java.sql.Time.class.equals(requiredType)) {
        value = rs.getTime(index);
    } else if (java.sql.Timestamp.class.equals(requiredType) || java.util.Date.class.equals(requiredType)) {
        value = rs.getTimestamp(index);
    } else if (BigDecimal.class.equals(requiredType)) {
        value = rs.getBigDecimal(index);
    } else if (Blob.class.equals(requiredType)) {
        value = rs.getBlob(index);
    } else if (Clob.class.equals(requiredType)) {
        value = rs.getClob(index);
    } else {
        // Some unknown type desired -> rely on getObject.
        value = getResultSetValue(rs, index);
    }

    // Perform was-null check if demanded (for results that the
    // JDBC driver returns as primitives).
    if (wasNullCheck && value != null && rs.wasNull()) {
        value = null;
    }
    return value;
}

From source file:com.floreantpos.actions.ClockInOutAction.java

public void performDriverIn(User user) {
    try {/*from  w w w. j  a  v  a  2s . com*/
        if (user == null) {
            return;
        }
        if (!user.isClockedIn()) {
            POSMessageDialog.showMessage(POSUtil.getFocusedWindow(), Messages.getString("ClockInOutAction.2")); //$NON-NLS-1$
            return;
        }

        EmployeeInOutHistoryDAO attendenceHistoryDAO = new EmployeeInOutHistoryDAO();
        EmployeeInOutHistory attendenceHistory = attendenceHistoryDAO.findDriverHistoryByClockedInTime(user);
        if (attendenceHistory == null) {
            attendenceHistory = new EmployeeInOutHistory();
            Date lastClockOutTime = user.getLastClockOutTime();
            Calendar c = Calendar.getInstance();
            c.setTime(lastClockOutTime);
            attendenceHistory.setOutTime(lastClockOutTime);
            attendenceHistory.setOutHour(Short.valueOf((short) c.get(Calendar.HOUR)));
            attendenceHistory.setUser(user);
            attendenceHistory.setTerminal(Application.getInstance().getTerminal());
            attendenceHistory.setShift(user.getCurrentShift());
        }

        Shift shift = user.getCurrentShift();
        Calendar calendar = Calendar.getInstance();

        user.setAvailableForDelivery(true);

        attendenceHistory.setClockOut(false);
        attendenceHistory.setInTime(calendar.getTime());
        attendenceHistory.setInHour(Short.valueOf((short) calendar.get(Calendar.HOUR_OF_DAY)));

        UserDAO.getInstance().saveDriverIn(user, attendenceHistory, shift, calendar);

        POSMessageDialog.showMessage(
                "Driver " + user.getFirstName() + " " + user.getLastName() + " is in after delivery"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    } catch (Exception e) {
        POSMessageDialog.showError(Application.getPosWindow(), e.getMessage(), e);
    }
}

From source file:org.mifos.accounts.productsmix.struts.action.ProductMixAction.java

@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    ProductMixActionForm prdMixActionForm = (ProductMixActionForm) form;
    SessionUtils.setAttribute(Constants.BUSINESS_KEY,
            getPrdMixBusinessService().getPrdOfferingByID(Short.valueOf(prdMixActionForm.getProductInstance())),
            request);/*from   w  ww .j a va 2s .com*/
    UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY,
            request.getSession());
    SessionUtils.setCollectionAttribute(ProductDefinitionConstants.PRODUCTTYPELIST,
            getProductTypes(userContext), request);
    if (StringUtils.isNotBlank(prdMixActionForm.getProductType())
            && prdMixActionForm.getProductType().equals(ProductType.LOAN.getValue().toString())) {
        List<LoanOfferingBO> loanOffInstance = ((ProductMixBusinessService) getService())
                .getAllLoanOfferings(getUserContext(request).getLocaleId());
        SessionUtils.setCollectionAttribute(ProductDefinitionConstants.PRODUCTINSTANCELIST, loanOffInstance,
                request);

    } else if (StringUtils.isNotBlank(prdMixActionForm.getProductType())
            && prdMixActionForm.getProductType().equals(ProductType.SAVINGS.getValue().toString())) {
        List<SavingsOfferingBO> savingOffInstance = ((ProductMixBusinessService) getService())
                .getAllSavingsProducts();
        SessionUtils.setCollectionAttribute(ProductDefinitionConstants.PRODUCTINSTANCELIST, savingOffInstance,
                request);
    }

    if (StringUtils.isNotBlank(prdMixActionForm.getProductType())) {

        List<PrdOfferingBO> prdOfferingList = ((ProductMixBusinessService) getService())
                .getAllowedPrdOfferingsByType(prdMixActionForm.getProductInstance(),
                        prdMixActionForm.getProductType());

        List<PrdOfferingBO> notAllowedPrdOfferingList = ((ProductMixBusinessService) getService())
                .getNotAllowedPrdOfferingsByType(prdMixActionForm.getProductInstance());

        SessionUtils.setCollectionAttribute(ProductDefinitionConstants.ALLOWEDPRODUCTLIST, prdOfferingList,
                request);
        SessionUtils.setCollectionAttribute(ProductDefinitionConstants.NOTALLOWEDPRODUCTLIST,
                notAllowedPrdOfferingList, request);
        SessionUtils.setCollectionAttribute(ProductDefinitionConstants.PRODUCTOFFERINGLIST, prdOfferingList,
                request);
        SessionUtils.setCollectionAttribute(ProductDefinitionConstants.OLDNOTALLOWEDPRODUCTLIST,
                notAllowedPrdOfferingList, request);
    }

    return mapping.findForward(ActionForwards.manage_success.toString());
}

From source file:com.eislab.af.translator.Translator_hub_i.java

private static String findOutgoingIpV6GivenAddress(String remoteIP) throws Exception {

    System.out.println("remoteIP: " + remoteIP);
    if (remoteIP.startsWith("[")) {
        remoteIP = remoteIP.substring(1, remoteIP.length() - 1);
        System.out.println("remoteIP: " + remoteIP);
    }/* w  w w.  j a  v  a  2  s . com*/

    if (System.getProperty("os.name").contains("Windows")) {
        NetworkInterface networkInterface;

        //if ipv6 then find the ipaddress of the network interface
        String line;
        short foundIfIndex = 0;
        final String COMMAND = "route print -6";
        List<RouteInfo> routes = new ArrayList<>();
        try {
            Process exec = Runtime.getRuntime().exec(COMMAND);
            BufferedReader reader = new BufferedReader(new InputStreamReader(exec.getInputStream()));
            //\s+addr:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+Bcast:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+Mask:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$
            Pattern p = Pattern.compile("^\\s*(\\d+)\\s+(\\d+)\\s+(.*)\\s+(.*)$");
            while ((line = reader.readLine()) != null) {
                //do not check persistent routes. Only active routes
                if (line.startsWith("Persistent Routes")) {
                    break;
                }

                Matcher match = p.matcher(line);
                if (match.matches()) {
                    //                     System.out.println("line match: " + line);
                    String network = match.group(3).split("/")[0];
                    //String mask = match.group(2);
                    //String address = match.group(3);
                    short maskLength = Short.valueOf(match.group(3).split("/")[1].trim());

                    boolean networkMatch = ipv6InRange(network, maskLength, remoteIP);

                    if (networkMatch) {
                        short interfaceIndex = Short.valueOf(match.group(1));
                        short metric = Short.valueOf(match.group(2));
                        routes.add(new RouteInfo("", interfaceIndex, maskLength, metric));
                        System.out.println("added route: " + line);
                    }
                }
            }
            Collections.sort(routes);
            for (RouteInfo route : routes) {
            }

            if (!routes.isEmpty()) {
                foundIfIndex = routes.get(0).ifIndex;

                //based o nthe network interface index get the ip address
                networkInterface = NetworkInterface.getByIndex(foundIfIndex);

                Enumeration<InetAddress> test = networkInterface.getInetAddresses();

                while (test.hasMoreElements()) {
                    InetAddress inetaddress = test.nextElement();
                    if (inetaddress.isLinkLocalAddress()) {
                        continue;
                    } else {
                        if (inetaddress instanceof Inet6Address) {
                            System.out.println("interface host address: " + inetaddress.getHostAddress());
                            return "[" + inetaddress.getHostAddress() + "]";
                        } else
                            continue;
                    }
                }
            } else { //routes is Empty!
                System.out.println("No routable interface for remote IP");
                throw new Exception("No routable interface for remote IP");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            throw ex;
        }
    } else {

        List<RouteInfo> routes = new ArrayList<>();
        try {
            //ipv6 ^(.+)/(\d+)\s+(.+)\s(\d+)\s+(\d+)\s+(\d)\s+(.+)$
            //ipv4 ^\s+inet\s\addr:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+Bcast:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+Mask:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$
            //linux route get command parsing: ipv4^.*via.*\s+dev\s+.*\s+src\s((?:[0-9\.]{1,3})+)
            //linux route get comand parsing: ipv6 ^.*\sfrom\s::\svia.*\sdev\s.*\ssrc\s((?:[:]{1,2}|[0-9|a|b|c|d|e|f]{1,4})+)
            //new one ^.*\s+from\s+::\s+via.*\s+dev\s+.*\ssrc\s+((?:[:]{1,2}|[0-9|a|b|c|d|e|f]{1,4})+)\s+metric\s+\d+
            //final String COMMAND = "/sbin/ifconfig";
            final String COMMAND = "ip route get " + remoteIP;

            System.out.println("command = " + COMMAND);

            Process exec = Runtime.getRuntime().exec(COMMAND);
            BufferedReader reader = new BufferedReader(new InputStreamReader(exec.getInputStream()));

            System.out.println(System.getProperty("os.name"));
            String line;
            /* examples:
             * fdfd:55::98ac from :: via fdfd:55::98ac dev usb0  src fdfd:55::80fe  metric 0
            */
            Pattern p = Pattern.compile(
                    "^.*\\s+from\\s+::\\s+via.*\\sdev\\s+.*\\s+src\\s+((?:[:]{1,2}|[0-9|a|b|c|d|e|f]{1,4})+)\\s+metric\\s+\\d+.*");
            //String test = "fdfd:55::80ff from :: via fdfd:55::80ff dev usb0  src fdfd:55::80fe  metric 0";
            while ((line = reader.readLine()) != null) {
                System.out.println("result of command = " + line);
                Matcher match = p.matcher(line);
                if (match.matches()) {

                    String address = match.group(1);
                    System.out.println("match found. address = " + address);
                    routes.add(new RouteInfo(address, (short) 0, (short) 0, (short) 0));//metric is always 0, because we do not extract it from the ifconfig command.

                }
            }
            Collections.sort(routes);

            if (!routes.isEmpty())
                return routes.get(0).source;

        } catch (Exception ex) {
            ex.printStackTrace();
        }

        //^\s+inet6\s+addr:\s+((?:[:]{1,2}|[0-9|a|b|c|d|e|f]{1,4})+)/(\d{1,3})\s+\Scope:Global$
        //           NetworkInterface networkInterface;
        //         
        //         //if ipv6 then find the ipaddress of the network interface
        //          String line;
        //          short foundIfIndex = 0;
        //         final String COMMAND = "/sbin/ifconfig";
        //         List<RouteInfo> routes = new ArrayList<>();
        //         try {
        //            Process exec = Runtime.getRuntime().exec(COMMAND);
        //            BufferedReader reader = new BufferedReader(new InputStreamReader(exec.getInputStream()));
        //            //\s+addr:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+Bcast:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+Mask:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$
        //            Pattern p = Pattern.compile("^\\s+inet6\\s+addr:\\s+((?:[:]{1,2}|[0-9|a|b|c|d|e|f]{1,4})+)/(\\d{1,3})\\s+\\Scope:Global$");
        //              while ((line = reader.readLine()) != null) {
        //                 //do not check persistent routes. Only active routes
        //                 if(line.startsWith("Persistent Routes")) {
        //                    break;
        //                 }
        //                 
        //                  Matcher match = p.matcher(line);
        //                  if (match.matches()) {
        //                      String network = match.group(1).trim();
        //                      short maskLength = Short.valueOf(match.group(2).trim());
        //                      
        //                      boolean networkMatch = ipv6InRange(network, maskLength, remoteIP);
        //                      
        //                      if (networkMatch) {
        //                         short interfaceIndex = Short.valueOf(match.group(1));
        //                          short metric = Short.valueOf(match.group(2));
        //                          routes.add(new RouteInfo("", interfaceIndex, maskLength, metric));
        //                          System.out.println("added route: " + line);
        //                      }
        //                  }
        //              }
        //              Collections.sort(routes);
        //              for (RouteInfo route : routes) {
        //              }
        //              
        //              if (!routes.isEmpty()) {
        //                 foundIfIndex = routes.get(0).ifIndex;
        //         
        //               //based o nthe network interface index get the ip address
        //               networkInterface = NetworkInterface.getByIndex(foundIfIndex);
        //            
        //               Enumeration<InetAddress> test = networkInterface.getInetAddresses();
        //               
        //               while (test.hasMoreElements()) {
        //                  InetAddress inetaddress = test.nextElement();
        //                  if (inetaddress.isLinkLocalAddress()) {
        //                     continue;
        //                  } else {
        //                     if (inetaddress instanceof Inet6Address) {
        //                        System.out.println("interface host address: " + inetaddress.getHostAddress());
        //                        return "[" + inetaddress.getHostAddress() + "]";
        //                     } else continue;
        //                  }
        //               }
        //              } else { //routes is Empty!
        //                 System.out.println("No routable interface for remote IP");
        //               throw new Exception("No routable interface for remote IP");
        //              }
        //         } catch (Exception ex) {
        //            ex.printStackTrace();
        //            throw ex;
        //         }

    }

    return null;
}

From source file:org.mifos.customers.office.struts.action.OffAction.java

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    OffActionForm actionForm = (OffActionForm) form;
    if (StringUtils.isBlank(actionForm.getOfficeId())) {
        throw new OfficeException(OfficeConstants.KEYGETFAILED);
    }//from w w w  .  ja v  a  2s.c o m

    OfficeDto officeDto = this.officeServiceFacade.retrieveOfficeById(Short.valueOf(actionForm.getOfficeId()));
    actionForm.clear();
    List<CustomFieldDefinitionEntity> customFieldDefs = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs, request);
    actionForm.populate(officeDto);
    SessionUtils.setAttribute(OfficeConstants.OFFICE_DTO, officeDto, request);
    setCurrentPageUrl(request, officeDto);
    return mapping.findForward(ActionForwards.get_success.toString());
}

From source file:org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.AbstractFeatureConverter.java

protected Serializable getValueForMetacardAttribute(AttributeFormat attributeFormat,
        HierarchicalStreamReader reader) {

    Serializable ser = null;/*from   ww w .  j  a  v  a2  s  .  co  m*/
    switch (attributeFormat) {
    case BOOLEAN:
        ser = Boolean.valueOf(reader.getValue());
        break;
    case DOUBLE:
        ser = Double.valueOf(reader.getValue());
        break;
    case FLOAT:
        ser = Float.valueOf(reader.getValue());
        break;
    case INTEGER:
        ser = Integer.valueOf(reader.getValue());
        break;
    case LONG:
        ser = Long.valueOf(reader.getValue());
        break;
    case SHORT:
        ser = Short.valueOf(reader.getValue());
        break;
    case XML:
    case STRING:
        ser = reader.getValue();
        break;
    case GEOMETRY:
        XmlNode node = new XmlNode(reader);
        String xml = node.toString();
        GMLReader gmlReader = new GMLReader();
        Geometry geo = null;
        try {
            geo = gmlReader.read(xml, null);
        } catch (SAXException e) {
            LOGGER.warn(ERROR_PARSING_MESSAGE, e);
        } catch (IOException e) {
            LOGGER.warn(ERROR_PARSING_MESSAGE, e);
        } catch (ParserConfigurationException e) {
            LOGGER.warn(ERROR_PARSING_MESSAGE, e);
        }
        if (geo != null) {
            WKTWriter wktWriter = new WKTWriter();
            ser = wktWriter.write(geo);
        }
        break;
    case BINARY:
        try {
            ser = reader.getValue().getBytes(UTF8_ENCODING);
        } catch (UnsupportedEncodingException e) {
            LOGGER.warn("Error encoding the binary value into the metacard.", e);
        }
        break;
    case DATE:
        ser = parseDateFromXml(reader);
        break;
    default:
        break;
    }
    return ser;

}