Example usage for org.apache.commons.lang StringUtils isNumeric

List of usage examples for org.apache.commons.lang StringUtils isNumeric

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils isNumeric.

Prototype

public static boolean isNumeric(String str) 

Source Link

Document

Checks if the String contains only unicode digits.

Usage

From source file:kr.co.aim.nanoframe.nanoFrameServiceProxy.java

@Override
public void start(BundleContext bundleContext) throws Exception {
    Bundle systemBundle = bundleContext.getBundle(0);
    setBundleContext(systemBundle.getBundleContext());

    addSystemProperty();/*from   w  w  w .  ja va  2 s .com*/

    bundleContext.registerService(CommandProvider.class.getName(), new NanoFrameCommand(), new Properties());

    String timeout = System.getProperty(nanoFrameProperties.BPEL_COMPLETION_TIMEOUT);
    if (StringUtils.isNotEmpty(timeout) && StringUtils.isNumeric(timeout))
        bpelCompletionTimeout = Integer.parseInt(timeout);
}

From source file:hydrograph.ui.engine.util.FTPUtil.java

/**
 * Converts the String to {@link BigInteger} for port
 * @param propertyName/*from   w ww .j a va 2 s. co  m*/
 * @param componentId
 * @param propertyValue
 * @return
 */
public BigInteger getPortParam(String propertyName, String componentId, Map<String, Object> properties) {
    LOGGER.debug("Getting boolean Value for {}={}", new Object[] { propertyName, properties });
    BigInteger bigInteger = null;
    FTPProtocolDetails protocolDetails = (FTPProtocolDetails) properties
            .get(PropertyNameConstants.PROTOCOL_SELECTION.value());
    if (StringUtils.isNotBlank(protocolDetails.getPort()) && StringUtils.isNumeric(protocolDetails.getPort())) {
        bigInteger = new BigInteger(String.valueOf(protocolDetails.getPort()));
    } else if (ParameterUtil.isParameter(protocolDetails.getPort())) {
        ComponentXpath.INSTANCE.getXpathMap()
                .put((ComponentXpathConstants.COMPONENT_XPATH_BOOLEAN.value().replace("$id", componentId))
                        .replace(Constants.PARAM_PROPERTY_NAME, propertyName),
                        new ComponentsAttributeAndValue(null, protocolDetails.getPort()));
        return null;
    }
    return bigInteger;
}

From source file:morphy.command.ClearmessagesCommand.java

public void process(String arguments, UserSession userSession) {
    /*  clearmessages *//from   w  w w . ja  v a 2  s  .c o m
      will delete all of your messages.
       clearmessages 2
      will delete your message #2.
       clearmessages DAV
      will delete all of your messages from DAV.
       clearmessages 4-7
      will delete your messages 4 through 7.
     */
    /*   clearmessage 38-40
       Messages 38-40 cleared.
    */
    /*   clearmessages 37-40
       You have no messages 37-40.
     */
    /*   You have 36 messages (1 unread).
       Use "messages u" to view unread messages and "clearmessages *" to clear all.
    */

    arguments = arguments.trim();
    if (arguments.equals("")) {
        userSession.send(getContext().getUsage());
        return;
    } else {
        if (!UserService.getInstance().isRegistered(userSession.getUser().getUserName())) {
            userSession.send("Only registered players can use the clearmessages command.");
            return;
        }

        int numMessages = 0;
        String query = "SELECT COUNT(*) FROM `messages` WHERE `to_user_id` = '"
                + userSession.getUser().getDBID() + "';";
        ResultSet rs = DatabaseConnectionService.getInstance().getDBConnection().executeQueryWithRS(query);
        try {
            if (rs.next()) {
                numMessages = rs.getInt(1);
            }
        } catch (SQLException e) {
            e.printStackTrace(System.err);
        }

        if (numMessages == 0) {
            userSession.send("You have no messages.");
            return;
        }

        if (arguments.equals("*")) {
            // delete all messages

            query = "DELETE FROM `messages` WHERE `to_user_id` = '" + userSession.getUser().getDBID() + "'";
            boolean executed = DatabaseConnectionService.getInstance().getDBConnection().executeQuery(query);
            if (executed) {
                userSession.send("Messages cleared.");
                return;
            }
        }

        if (StringUtils.isNumeric(arguments)) {
            // delete this message

            arguments += "-" + arguments;
            //return;
        }

        if (StringUtils.isAlpha(arguments)) {
            // delete all messages from this user

            int id = UserService.getInstance().getDBID(arguments);
            if (id == 0) { /* something failed */
                userSession.send("There is no player matching the name " + arguments + ".");
                return;
            } else {
                /*   clearmessages outrunyou
                   You have no messages from OUTRUNYOU.
                */

                String username = UserService.getInstance().correctCapsUsername(arguments);

                query = "SELECT `id` FROM `messages` WHERE `from_user_id` = '" + id + "' ORDER BY `id` ASC";
                rs = DatabaseConnectionService.getInstance().getDBConnection().executeQueryWithRS(query);
                try {
                    List<Integer> ids = new ArrayList<Integer>();
                    while (rs.next()) {
                        ids.add(new Integer(rs.getInt(1)));
                    }
                    if (ids.size() == 0) {
                        userSession.send("You have no messages from " + username + ".");
                        return;
                    } else {
                        query = "DELETE FROM `messages` WHERE "
                                + MessagesCommand.formatIdListForQuery("id", ids);
                        boolean executed = DatabaseConnectionService.getInstance().getDBConnection()
                                .executeQuery(query);
                        if (executed) {
                            userSession.send("Messages from " + username + " cleared.");
                            return;
                        }
                    }
                } catch (SQLException e) {
                    e.printStackTrace(System.err);
                }
            }
            return;
        }

        if (arguments.matches("[0-9]+\\-[0-9]+")) {
            // delete this range of messages
            List<Integer> list = MessagesCommand.expandRange(arguments);
            java.util.Collections.sort(list);
            query = "SELECT m.`id`,u1.`username`,`message`,`timestamp`,`read` "
                    + "FROM `messages` m INNER JOIN `users` u1 ON (u1.`id` = m.`from_user_id`) "
                    + "WHERE m.to_user_id = '" + userSession.getUser().getDBID() + "'" + "ORDER BY m.`id` ASC";
            rs = DatabaseConnectionService.getInstance().getDBConnection().executeQueryWithRS(query);
            try {
                // the "ids" variable contains the actual message ids as stored in the database
                // and NOT the psuedo message number as the user thinks.
                List<Integer> ids = new ArrayList<Integer>();
                List<Integer> rownums = new ArrayList<Integer>();
                int rownum = 0;
                while (rs.next()) {
                    rownum++;
                    if (list.contains(rownum)) {
                        ids.add(rs.getInt(1));
                        rownums.add(rownum);
                    }
                }
                if (ids.size() > 0) {
                    query = "DELETE FROM `messages` WHERE " + MessagesCommand.formatIdListForQuery("id", ids);
                    boolean executed = DatabaseConnectionService.getInstance().getDBConnection()
                            .executeQuery(query);
                    if (executed) {
                        userSession.send((rownums.size() == 1 ? "Message" : "Messages") + " "
                                + rownums.toString() + " cleared.");
                        return;
                    }
                } else {
                    userSession.send("You have no message" + (rownums.size() > 1 ? "s" : "") + " "
                            + rownums.toString() + ".");
                    return;
                }
            } catch (SQLException e) {
                e.printStackTrace(System.err);
            }

            return;
        }

        // if we've reached this point, nothing has been deleted, so invalid arguments.
        userSession.send(getContext().getUsage());
        return;
    }
}

From source file:edu.harvard.iq.dataverse.DatasetFieldValueValidator.java

public boolean isValid(DatasetFieldValue value, ConstraintValidatorContext context) {

    context.disableDefaultConstraintViolation(); // we do this so we can have different messages depending on the different issue

    boolean lengthOnly = false;

    DatasetFieldType dsfType = value.getDatasetField().getDatasetFieldType();
    FieldType fieldType = dsfType.getFieldType();

    if (value.getDatasetField().getTemplate() != null) {
        lengthOnly = true;//from  w  ww  .  j  a  v  a 2s  .  co  m
    }

    if (value.getDatasetField().getParentDatasetFieldCompoundValue() != null && value.getDatasetField()
            .getParentDatasetFieldCompoundValue().getParentDatasetField().getTemplate() != null) {
        lengthOnly = true;
    }

    if (StringUtils.isBlank(value.getValue()) || StringUtils.equals(value.getValue(), DatasetField.NA_VALUE)) {
        return true;
    }

    if (fieldType.equals(FieldType.TEXT) && !lengthOnly
            && value.getDatasetField().getDatasetFieldType().getValidationFormat() != null) {
        boolean valid = value.getValue()
                .matches(value.getDatasetField().getDatasetFieldType().getValidationFormat());
        if (!valid) {
            try {
                context.buildConstraintViolationWithTemplate(
                        dsfType.getDisplayName() + " is not a valid entry.").addConstraintViolation();
            } catch (NullPointerException e) {
                return false;
            }
            return false;
        }
    }

    if (fieldType.equals(FieldType.DATE) && !lengthOnly) {
        boolean valid = false;
        String testString = value.getValue();

        if (!valid) {
            valid = isValidDate(testString, "yyyy-MM-dd");
        }
        if (!valid) {
            valid = isValidDate(testString, "yyyy-MM");
        }

        //If AD must be a 4 digit year
        if (value.getValue().contains("AD")) {
            testString = (testString.substring(0, testString.indexOf("AD"))).trim();
        }

        String YYYYformat = "yyyy";
        if (!valid) {
            valid = isValidDate(testString, YYYYformat);
            if (!StringUtils.isNumeric(testString)) {
                valid = false;
            }
        }

        //If BC must be numeric
        if (!valid && value.getValue().contains("BC")) {
            testString = (testString.substring(0, testString.indexOf("BC"))).trim();
            if (StringUtils.isNumeric(testString)) {
                valid = true;
            }
        }

        // Validate Bracket entries
        // Must start with "[", end with "?]" and not start with "[-"
        if (!valid && value.getValue().startsWith("[") && value.getValue().endsWith("?]")
                && !value.getValue().startsWith("[-")) {
            testString = value.getValue().replace("[", " ").replace("?]", " ").replace("-", " ")
                    .replace("BC", " ").replace("AD", " ").trim();
            if (value.getValue().contains("BC") && StringUtils.isNumeric(testString)) {
                valid = true;
            } else {
                valid = isValidDate(testString, YYYYformat);
                if (!StringUtils.isNumeric(testString)) {
                    valid = false;
                }
            }
        }

        if (!valid) {
            // TODO: 
            // This is a temporary fix for the early beta! 
            // (to accommodate dates with time stamps from Astronomy files)
            // As a real fix, we need to introduce a different type - 
            // "datetime" for ex. and use it for timestamps; 
            // We do NOT want users to be able to enter a full time stamp
            // as the release date... 
            // -- L.A. 4.0 beta 

            valid = (isValidDate(value.getValue(), "yyyy-MM-dd'T'HH:mm:ss")
                    || isValidDate(value.getValue(), "yyyy-MM-dd'T'HH:mm:ss.SSS")
                    || isValidDate(value.getValue(), "yyyy-MM-dd HH:mm:ss"));

        }
        if (!valid) {
            try {
                context.buildConstraintViolationWithTemplate(dsfType.getDisplayName()
                        + " is not a valid date. \"" + YYYYformat + "\" is a supported format.")
                        .addConstraintViolation();
            } catch (NullPointerException npe) {

            }

            return false;
        }
    }

    if (fieldType.equals(FieldType.FLOAT) && !lengthOnly) {
        try {
            Double.parseDouble(value.getValue());
        } catch (Exception e) {
            logger.fine("Float value failed validation: " + value.getValue() + " (" + dsfType.getDisplayName()
                    + ")");
            try {
                context.buildConstraintViolationWithTemplate(
                        dsfType.getDisplayName() + " is not a valid number.").addConstraintViolation();
            } catch (NullPointerException npe) {

            }

            return false;
        }
    }

    if (fieldType.equals(FieldType.INT) && !lengthOnly) {
        try {
            Integer.parseInt(value.getValue());
        } catch (Exception e) {
            try {
                context.buildConstraintViolationWithTemplate(
                        dsfType.getDisplayName() + " is not a valid integer.").addConstraintViolation();
            } catch (NullPointerException npe) {

            }

            return false;
        }
    }
    // Note, length validation for FieldType.TEXT was removed to accommodate migrated data that is greater than 255 chars.

    if (fieldType.equals(FieldType.URL) && !lengthOnly) {
        try {
            URL url = new URL(value.getValue());
        } catch (MalformedURLException e) {
            try {
                context.buildConstraintViolationWithTemplate(
                        dsfType.getDisplayName() + " " + value.getValue() + "  is not a valid URL.")
                        .addConstraintViolation();
            } catch (NullPointerException npe) {

            }

            return false;
        }
    }

    if (fieldType.equals(FieldType.EMAIL) && !lengthOnly) {
        if (value.getDatasetField().isRequired() && value.getValue() == null) {
            return false;
        }

        return EMailValidator.isEmailValid(value.getValue(), context);

    }

    return true;
}

From source file:co.mcme.warps.commands.WarpSearchCommand.java

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player)) {
        sender.sendMessage("You must be a player to run this command.");
        return true;
    }/*w  w w . j a va 2 s. c  om*/
    Player player = (Player) sender;
    if (args.length > 0) {
        String search = args[0];
        if (search.toLowerCase().contains("@")) {
            search = search.replaceAll("@", "");
            if (WarpDatabase.getWarpCreators().containsKey(search)) {
                ArrayList<PlayerWarp> warps = WarpDatabase.getWarpCreators().get(search).getWarps();
                StringBuilder customList = new StringBuilder();
                boolean first = true;
                for (PlayerWarp warp : warps) {
                    if (!first) {
                        customList.append("\n");
                    }
                    ChatColor col = ChatColor.GREEN;
                    if (warp.isInviteonly()) {
                        col = ChatColor.RED;
                    }
                    Date date = new Date(warp.getCreateStamp());
                    customList.append(col).append(warp.getName()).append(ChatColor.GRAY).append(" created by ")
                            .append(ChatColor.AQUA).append(warp.getOwner()).append(ChatColor.GRAY)
                            .append(" on ").append(ChatColor.AQUA).append(Warps.getDateformat().format(date));
                    if (first) {
                        first = false;
                    }
                }
                if (args.length > 1 && StringUtils.isNumeric(args[1])) {
                    ChatPaginator.ChatPage page = ChatPaginator.paginate(customList.toString(),
                            Integer.valueOf(args[1]), ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH, 8);
                    sender.sendMessage(
                            ChatColor.GRAY + search + "'s warps " + ChatColor.AQUA + page.getPageNumber()
                                    + ChatColor.GRAY + " of " + ChatColor.AQUA + page.getTotalPages());
                    for (String line : page.getLines()) {
                        sender.sendMessage(line);
                    }
                    return true;
                } else {
                    ChatPaginator.ChatPage page = ChatPaginator.paginate(customList.toString(), 1,
                            ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH, 8);
                    sender.sendMessage(
                            ChatColor.GRAY + search + "'s warps " + ChatColor.AQUA + page.getPageNumber()
                                    + ChatColor.GRAY + " of " + ChatColor.AQUA + page.getTotalPages());
                    for (String line : page.getLines()) {
                        sender.sendMessage(line);
                    }
                    return true;
                }
            } else {
                sender.sendMessage(ChatColor.RED + "Cannot find any warps by " + search);
                return true;
            }
        }
        SearchResult res = SearchWarps.searchWarps(search, player);
        StringBuilder exactLines = new StringBuilder();
        boolean first = true;
        for (PlayerWarp warp : res.getExact()) {
            if (!first) {
                exactLines.append("\n");
            }
            ChatColor col = ChatColor.GREEN;
            if (warp.isInviteonly()) {
                col = ChatColor.RED;
            }
            Date date = new Date(warp.getCreateStamp());
            exactLines.append(col).append(warp.getName()).append(ChatColor.GRAY).append(" created by ")
                    .append(ChatColor.AQUA).append(warp.getOwner()).append(ChatColor.GRAY).append(" on ")
                    .append(ChatColor.AQUA).append(Warps.getDateformat().format(date));
            if (first) {
                first = false;
            }
        }

        StringBuilder partialLines = new StringBuilder();
        first = true;
        for (PlayerWarp warp : res.getPartial()) {
            if (!first) {
                partialLines.append("\n");
            }
            ChatColor col = ChatColor.GREEN;
            if (warp.isInviteonly()) {
                col = ChatColor.RED;
            }
            Date date = new Date(warp.getCreateStamp());
            partialLines.append(col).append(warp.getName()).append(ChatColor.GRAY).append(" created by ")
                    .append(ChatColor.AQUA).append(warp.getOwner()).append(ChatColor.GRAY).append(" on ")
                    .append(ChatColor.AQUA).append(Warps.getDateformat().format(date));
            if (first) {
                first = false;
            }
        }
        if (res.getExact().size() > 0) {
            ChatPaginator.ChatPage page = ChatPaginator.paginate(partialLines.toString(), 1,
                    ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH, 8);
            sender.sendMessage(ChatColor.GRAY + "Exact Matches for " + args[0]);
            for (String line : page.getLines()) {
                sender.sendMessage(line);
            }
            return true;
        }
        if (res.getPartial().size() > 0) {
            if (args.length > 1) {
                ChatPaginator.ChatPage page = ChatPaginator.paginate(partialLines.toString(),
                        Integer.valueOf(args[1]), ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH, 8);
                sender.sendMessage(
                        ChatColor.GRAY + "Partial Matches page " + ChatColor.AQUA + page.getPageNumber()
                                + ChatColor.GRAY + " of " + ChatColor.AQUA + page.getTotalPages());
                for (String line : page.getLines()) {
                    sender.sendMessage(line);
                }
                return true;
            } else {
                ChatPaginator.ChatPage page = ChatPaginator.paginate(partialLines.toString(), 1,
                        ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH, 8);
                sender.sendMessage(
                        ChatColor.GRAY + "Partial Matches page " + ChatColor.AQUA + page.getPageNumber()
                                + ChatColor.GRAY + " of " + ChatColor.AQUA + page.getTotalPages());
                for (String line : page.getLines()) {
                    sender.sendMessage(line);
                }
                return true;
            }
        }
        sender.sendMessage(ChatColor.RED + "No warps found for " + args[0]);
        return true;
    }
    return false;
}

From source file:elaborate.publication.resources.SearchResource.java

@GET
@Path("{search_id:[0-9]+}")
@Produces(UTF8MediaType.APPLICATION_JSON)
public Response getSearchResults(//
        @PathParam("search_id") long searchId, //
        @QueryParam("start") @DefaultValue("0") String startString, //
        @QueryParam("rows") @DefaultValue("100") String rowsString//
) {//from  w w  w  .jav  a  2 s.  c o  m
    if (!StringUtils.isNumeric(startString) || !StringUtils.isNumeric(rowsString)) {
        throw new BadRequestException();
    }
    int start = Integer.valueOf(startString);
    int rows = Integer.valueOf(rowsString);
    Map<String, Object> searchResult = searchService.getSearchResult(searchId, start, rows);
    addPrevNextURIs(searchResult, searchId, start, rows);
    ResponseBuilder builder = Response.ok(searchResult);
    return builder.build();
}

From source file:fr.paris.lutece.plugins.workflow.modules.rest.service.resourceinfo.StateInfoProvider.java

/**
 * {@inheritDoc}//from  w ww.  ja va2  s  .c  o m
 */
@Override
public boolean isInvoked(Map<String, String> mapParams) {
    boolean bIsInvoked = false;

    if ((mapParams != null) && (mapParams.size() == 3)) {
        String strIdResource = mapParams.get(WorkflowRestConstants.PARAMETER_ID_RESOURCE);
        String strResourceType = mapParams.get(WorkflowRestConstants.PARAMETER_RESOURCE_TYPE);
        String strIdWorkflow = mapParams.get(WorkflowRestConstants.PARAMETER_ID_WORKFLOW);

        if (StringUtils.isNotBlank(strIdResource) && StringUtils.isNumeric(strIdResource)
                && StringUtils.isNotBlank(strIdWorkflow) && StringUtils.isNumeric(strIdWorkflow)
                && StringUtils.isNotBlank(strResourceType)) {
            bIsInvoked = true;
        }
    }

    return bIsInvoked;
}

From source file:com.lm.lic.manager.controller.WithdrawLicController.java

@Override
protected Map<String, Object> referenceData(HttpServletRequest request, Object command, Errors errors)
        throws Exception {
    WithdrawLicForm wlc = (WithdrawLicForm) command;
    Map<String, Object> refData = new HashMap<String, Object>();

    Product product = null;//from  ww  w . ja va  2  s  .  c  o  m
    String prodName = wlc.getProduct();
    String prodVer = wlc.getVersion();

    String licKey = wlc.getLicKey();
    if (StringUtils.isNotBlank(licKey)) {
        if (wlc.getQty() == null || wlc.getQty() < 1)
            wlc.setQty(1);
    }

    String isvProductId = wlc.getProductId();
    String productKey = wlc.getProductKey();
    String isvId = GenUtil.findLoggedinIsv(request, loginService);
    if (StringUtils.isNotBlank(prodName) && StringUtils.isNotBlank(prodVer)) {
        product = productService.findProductByNameAndVersion(isvId, prodName, prodVer);
        if (product == null)
            product = productService.findProductByName(isvId, prodName);
    } else if (StringUtils.isNotBlank(isvProductId)) {
        product = productService.findProductByIsvProdId(isvId, isvProductId);
    } else if (StringUtils.isNotBlank(productKey)) {
        product = productService.findProductByProductKey(isvId, productKey);
    }

    if (product == null && StringUtils.isNumeric(wlc.getProdId()))
        product = productService.findProdById(isvId, wlc.getProdId());

    if (product != null) {
        wlc.setProductKey(product.getProductKey());
        wlc.setParamProductID(product.getIsvProductId());
    }

    RequestForLicense requestForLicense = (RequestForLicense) request.getAttribute("requestForLicense");
    wlc.setRequestForLicense(requestForLicense);

    wlc.setIsvId(isvId);

    String prodId = EMPTY;
    Boolean enabled = false;
    if (product != null) {
        popDefaultValues(wlc, product);
        prodId += product.getId();
        enabled = product.getEnabled();
        wlc.setProdDefKey(product.getProductDefKey());
        wlc.setIsvKey(product.getIsv().getIsvKey());
        wlc.setProductKey(product.getProductKey());
        wlc.setProdInstKey(product.getProductKey());
    }

    refData.put("isvId", isvId);
    refData.put("prodId", prodId);
    refData.put("product", product);
    refData.put("enabled", enabled);
    return refData;
}

From source file:com.impetus.kundera.property.accessor.SQLTimeAccessor.java

@Override
public Time fromString(Class targetClass, String s) {
    if (s == null) {
        return null;
    }//ww  w .j  a  v  a  2 s.  c  o m

    if (StringUtils.isNumeric(s)) {
        return new Time(Long.parseLong(s));
    }
    Time t = Time.valueOf(s);
    return t;
}

From source file:com.hexidec.ekit.component.PropertiesDialog.java

public PropertiesDialog(Window parent, String[] fields, String[] types, String[] values, String title,
        boolean bModal) {
    super(parent, title);
    setModal(bModal);/*w  w  w .  jav  a 2s. c om*/
    htInputFields = new Hashtable<String, JComponent>();
    final Object[] buttonLabels = { Translatrix.getTranslationString("DialogAccept"),
            Translatrix.getTranslationString("DialogCancel") };
    List<Object> panelContents = new ArrayList<Object>();
    for (int iter = 0; iter < fields.length; iter++) {
        String fieldName = fields[iter];
        String fieldType = types[iter];
        JComponent fieldComponent;
        JComponent panelComponent = null;
        if (fieldType.equals("text") || fieldType.equals("integer")) {
            fieldComponent = new JTextField(3);
            if (values[iter] != null && values[iter].length() > 0) {
                ((JTextField) (fieldComponent)).setText(values[iter]);
            }

            if (fieldType.equals("integer")) {
                ((AbstractDocument) ((JTextField) (fieldComponent)).getDocument())
                        .setDocumentFilter(new DocumentFilter() {

                            @Override
                            public void insertString(FilterBypass fb, int offset, String text,
                                    AttributeSet attrs) throws BadLocationException {
                                replace(fb, offset, 0, text, attrs);
                            }

                            @Override
                            public void replace(FilterBypass fb, int offset, int length, String text,
                                    AttributeSet attrs) throws BadLocationException {

                                if (StringUtils.isNumeric(text)) {
                                    super.replace(fb, offset, length, text, attrs);
                                }

                            }

                        });
            }
        } else if (fieldType.equals("bool")) {
            fieldComponent = new JCheckBox(fieldName);
            if (values[iter] != null) {
                ((JCheckBox) (fieldComponent)).setSelected(values[iter] == "true");
            }
            panelComponent = fieldComponent;
        } else if (fieldType.equals("combo")) {
            fieldComponent = new JComboBox();
            if (values[iter] != null) {
                StringTokenizer stParse = new StringTokenizer(values[iter], ",", false);
                while (stParse.hasMoreTokens()) {
                    ((JComboBox) (fieldComponent)).addItem(stParse.nextToken());
                }
            }
        } else {
            fieldComponent = new JTextField(3);
        }
        htInputFields.put(fieldName, fieldComponent);
        if (panelComponent == null) {
            panelContents.add(fieldName);
            panelContents.add(fieldComponent);
        } else {
            panelContents.add(panelComponent);
        }
    }
    jOptionPane = new JOptionPane(panelContents.toArray(), JOptionPane.QUESTION_MESSAGE,
            JOptionPane.OK_CANCEL_OPTION, null, buttonLabels, buttonLabels[0]);

    setContentPane(jOptionPane);
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    jOptionPane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();
            if (isVisible() && (e.getSource() == jOptionPane) && (prop.equals(JOptionPane.VALUE_PROPERTY)
                    || prop.equals(JOptionPane.INPUT_VALUE_PROPERTY))) {
                Object value = jOptionPane.getValue();
                if (value == JOptionPane.UNINITIALIZED_VALUE) {
                    return;
                }
                if (value.equals(buttonLabels[0])) {
                    setVisible(false);
                } else {
                    setVisible(false);
                }
            }
        }
    });
    this.pack();
    setLocation(SwingUtilities.getPointForCentering(this, parent));
}