Example usage for org.apache.commons.lang3 StringUtils deleteWhitespace

List of usage examples for org.apache.commons.lang3 StringUtils deleteWhitespace

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils deleteWhitespace.

Prototype

public static String deleteWhitespace(final String str) 

Source Link

Document

Deletes all whitespaces from a String as defined by Character#isWhitespace(char) .

 StringUtils.deleteWhitespace(null)         = null StringUtils.deleteWhitespace("")           = "" StringUtils.deleteWhitespace("abc")        = "abc" StringUtils.deleteWhitespace("   ab  c  ") = "abc" 

Usage

From source file:com.github.mavogel.ilias.utils.IOUtils.java

/**
 * Just reads the next line from System in and deleting whitespaces.
 *
 * @return the line//from   ww w .j  av a  2 s  . c  o m
 */
public static String readLine() {
    Scanner scanner = new Scanner(System.in);
    String nextLine = scanner.nextLine();
    return StringUtils.deleteWhitespace(nextLine);
}

From source file:com.sample.domain.entities.anagrafica.Cliente.java

public void setTelefonoCasa(String telefonoCasa) {
    this.telefonoCasa = StringUtils.deleteWhitespace(telefonoCasa);
}

From source file:io.bibleget.BibleGetFrame.java

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
    List<String> selectedVersions = new ArrayList<>();
    if (jList1.isSelectionEmpty()) {
        JOptionPane.showMessageDialog(null,
                __("You must select at least one version in order to make a request."),
                "ERROR >> NO VERSIONS SELECTED", JOptionPane.ERROR_MESSAGE);
        return;//from  ww w  .  jav a  2 s  .c  om
    } else {
        // Find out which indexes are selected.
        int minIndex = jList1.getMinSelectionIndex();
        int maxIndex = jList1.getMaxSelectionIndex();
        for (int i = minIndex; i <= maxIndex; i++) {
            if (jList1.isSelectedIndex(i)) {
                String abbrev = versionsByLang.get(i).getAbbrev();
                selectedVersions.add(abbrev);
            }
        }
    }
    String versionsSelcd = StringUtils.join(selectedVersions.toArray(), ',');

    String myInputContent = jTextField1.getText();
    myInputContent = StringUtils.deleteWhitespace(myInputContent);
    //System.out.println("You typed : "+myInputContent);

    HTTPCaller myHTTPCaller = new HTTPCaller();
    String myResponse;
    try {
        Boolean querycheck = myHTTPCaller.integrityCheck(myInputContent, selectedVersions);
        if (querycheck) {
            //JOptionPane.showMessageDialog(null, "All is proceeding nicely", "progress info", JOptionPane.INFORMATION_MESSAGE);
            myResponse = myHTTPCaller.sendGet(myInputContent, versionsSelcd);
            if (myResponse != null) {
                BibleGetJSON myJSON = new BibleGetJSON(m_xController);
                myJSON.JSONParse(myResponse);
                this.setVisible(false);
            } else {
                JOptionPane.showMessageDialog(null,
                        __("There was a problem communicating with the BibleGet server. Please try again."),
                        "ERROR >> SERVER CONNECTIVITY ISSUE", JOptionPane.ERROR_MESSAGE);
            }
        } else {
            String[] errorMessages = myHTTPCaller.getErrorMessages();
            String errorDialog = StringUtils.join(errorMessages, "\n\n");
            JOptionPane.showMessageDialog(null, errorDialog, "ERROR >> MALFORMED QUERYSTRING",
                    JOptionPane.ERROR_MESSAGE);
        }
    } catch (HeadlessException | ClassNotFoundException | UnknownPropertyException | PropertyVetoException
            | IllegalArgumentException | WrappedTargetException | UnsupportedEncodingException ex) {
        Logger.getLogger(BibleGetFrame.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:io.bitsquare.btc.WalletService.java

public void initialize(@Nullable DeterministicSeed seed, ResultHandler resultHandler,
        ExceptionHandler exceptionHandler) {
    Log.traceCall();//w  w  w  . j  ava  2s.c o m
    // Tell bitcoinj to execute event handlers on the JavaFX UI thread. This keeps things simple and means
    // we cannot forget to switch threads when adding event handlers. Unfortunately, the DownloadListener
    // we give to the app kit is currently an exception and runs on a library thread. It'll get fixed in
    // a future version.

    Threading.USER_THREAD = UserThread.getExecutor();

    Timer timeoutTimer = UserThread.runAfter(
            () -> exceptionHandler.handleException(
                    new TimeoutException("Wallet did not initialize in " + STARTUP_TIMEOUT_SEC + " seconds.")),
            STARTUP_TIMEOUT_SEC);

    backupWallet();

    final Socks5Proxy socks5Proxy = preferences.getUseTorForBitcoinJ() ? socks5ProxyProvider.getSocks5Proxy()
            : null;
    log.debug("Use socks5Proxy for bitcoinj: " + socks5Proxy);

    // If seed is non-null it means we are restoring from backup.
    walletAppKit = new WalletAppKitBitSquare(params, socks5Proxy, walletDir, "Bitsquare") {
        @Override
        protected void onSetupCompleted() {
            // Don't make the user wait for confirmations for now, as the intention is they're sending it
            // their own money!
            walletAppKit.wallet().allowSpendingUnconfirmedTransactions();
            final PeerGroup peerGroup = walletAppKit.peerGroup();

            if (params != RegTestParams.get())
                peerGroup.setMaxConnections(11);

            // We don't want to get our node white list polluted with nodes from AddressMessage calls.
            if (preferences.getBitcoinNodes() != null && !preferences.getBitcoinNodes().isEmpty())
                peerGroup.setAddPeersFromAddressMessage(false);

            wallet = walletAppKit.wallet();
            wallet.addEventListener(walletEventListener);

            addressEntryList.onWalletReady(wallet);

            peerGroup.addEventListener(new PeerEventListener() {
                @Override
                public void onPeersDiscovered(Set<PeerAddress> peerAddresses) {
                }

                @Override
                public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock filteredBlock,
                        int blocksLeft) {
                }

                @Override
                public void onChainDownloadStarted(Peer peer, int blocksLeft) {
                }

                @Override
                public void onPeerConnected(Peer peer, int peerCount) {
                    numPeers.set(peerCount);
                    connectedPeers.set(peerGroup.getConnectedPeers());
                }

                @Override
                public void onPeerDisconnected(Peer peer, int peerCount) {
                    numPeers.set(peerCount);
                    connectedPeers.set(peerGroup.getConnectedPeers());
                }

                @Override
                public Message onPreMessageReceived(Peer peer, Message m) {
                    return null;
                }

                @Override
                public void onTransaction(Peer peer, Transaction t) {
                }

                @Nullable
                @Override
                public List<Message> getData(Peer peer, GetDataMessage m) {
                    return null;
                }
            });

            // set after wallet is ready
            tradeWalletService.setWalletAppKit(walletAppKit);
            tradeWalletService.setAddressEntryList(addressEntryList);
            timeoutTimer.stop();

            // onSetupCompleted in walletAppKit is not the called on the last invocations, so we add a bit of delay
            UserThread.runAfter(resultHandler::handleResult, 100, TimeUnit.MILLISECONDS);
        }
    };

    // Bloom filters in BitcoinJ are completely broken
    // See: https://jonasnick.github.io/blog/2015/02/12/privacy-in-bitcoinj/
    // Here are a few improvements to fix a few vulnerabilities.

    // Bitsquare's BitcoinJ fork has added a bloomFilterTweak (nonce) setter to reuse the same seed avoiding the trivial vulnerability
    // by getting the real pub keys by intersections of several filters sent at each startup.
    walletAppKit.setBloomFilterTweak(bloomFilterTweak);

    // Avoid the simple attack (see: https://jonasnick.github.io/blog/2015/02/12/privacy-in-bitcoinj/) due to the 
    // default implementation using both pubkey and hash of pubkey. We have set a insertPubKey flag in BasicKeyChain to default false.

    // Default only 266 keys are generated (2 * 100+33). That would trigger new bloom filters when we are reaching 
    // the threshold. To avoid reaching the threshold we create much more keys which are unlikely to cause update of the
    // filter for most users. With lookaheadSize of 500 we get 1333 keys which should be enough for most users to 
    // never need to update a bloom filter, which would weaken privacy.
    walletAppKit.setLookaheadSize(500);

    // Calculation is derived from: https://www.reddit.com/r/Bitcoin/comments/2vrx6n/privacy_in_bitcoinj_android_wallet_multibit_hive/coknjuz
    // No. of false positives (56M keys in the blockchain): 
    // First attempt for FP rate:
    // FP rate = 0,0001;  No. of false positives: 0,0001 * 56 000 000  = 5600
    // We have 1333keys: 1333 / (5600 + 1333) = 0.19 -> 19 % probability that a pub key is in our wallet
    // After tests I found out that the bandwidth consumption varies widely related to the generated filter.
    // About 20- 40 MB for upload and 30-130 MB for download at first start up (spv chain).
    // Afterwards its about 1 MB for upload and 20-80 MB for download.
    // Probably better then a high FP rate would be to include foreign pubKeyHashes which are tested to not be used 
    // in many transactions. If we had a pool of 100 000 such keys (2 MB data dump) to random select 4000 we could mix it with our
    // 1000 own keys and get a similar probability rate as with the current setup but less variation in bandwidth 
    // consumption.

    // For now to reduce risks with high bandwidth consumption we reduce the FP rate by half.
    // FP rate = 0,00005;  No. of false positives: 0,00005 * 56 000 000  = 2800
    // 1333 / (2800 + 1333) = 0.32 -> 32 % probability that a pub key is in our wallet
    walletAppKit.setBloomFilterFalsePositiveRate(0.00005);

    String btcNodes = preferences.getBitcoinNodes();
    log.debug("btcNodes: " + btcNodes);
    boolean usePeerNodes = false;

    // Pass custom seed nodes if set in options
    if (!btcNodes.isEmpty()) {
        String[] nodes = StringUtils.deleteWhitespace(btcNodes).split(",");
        List<PeerAddress> peerAddressList = new ArrayList<>();
        for (String node : nodes) {
            String[] parts = node.split(":");
            if (parts.length == 1) {
                // port not specified.  Use default port for network.
                parts = new String[] { parts[0], Integer.toString(params.getPort()) };
            }
            if (parts.length == 2) {
                // note: this will cause a DNS request if hostname used.
                // note: DNS requests are routed over socks5 proxy, if used.
                // note: .onion hostnames will be unresolved.
                InetSocketAddress addr;
                if (socks5Proxy != null) {
                    try {
                        // proxy remote DNS request happens here.  blocking.
                        addr = new InetSocketAddress(DnsLookupTor.lookup(socks5Proxy, parts[0]),
                                Integer.parseInt(parts[1]));
                    } catch (Exception e) {
                        log.warn("Dns lookup failed for host: {}", parts[0]);
                        addr = null;
                    }
                } else {
                    // DNS request happens here. if it fails, addr.isUnresolved() == true.
                    addr = new InetSocketAddress(parts[0], Integer.parseInt(parts[1]));
                }
                if (addr != null && !addr.isUnresolved()) {
                    peerAddressList.add(new PeerAddress(addr.getAddress(), addr.getPort()));
                }
            }
        }
        if (peerAddressList.size() > 0) {
            PeerAddress peerAddressListFixed[] = new PeerAddress[peerAddressList.size()];
            log.debug("btcNodes parsed: " + Arrays.toString(peerAddressListFixed));

            walletAppKit.setPeerNodes(peerAddressList.toArray(peerAddressListFixed));
            usePeerNodes = true;
        }
    }

    // Now configure and start the appkit. This will take a second or two - we could show a temporary splash screen
    // or progress widget to keep the user engaged whilst we initialise, but we don't.
    if (params == RegTestParams.get()) {
        if (regTestHost == RegTestHost.REG_TEST_SERVER) {
            try {
                walletAppKit.setPeerNodes(
                        new PeerAddress(InetAddress.getByName(RegTestHost.SERVER_IP), params.getPort()));
                usePeerNodes = true;
            } catch (UnknownHostException e) {
                throw new RuntimeException(e);
            }
        } else if (regTestHost == RegTestHost.LOCALHOST) {
            walletAppKit.connectToLocalHost(); // You should run a regtest mode bitcoind locally.}
        }
    } else if (params == MainNetParams.get()) {
        // Checkpoints are block headers that ship inside our app: for a new user, we pick the last header
        // in the checkpoints file and then download the rest from the network. It makes things much faster.
        // Checkpoint files are made using the BuildCheckpoints tool and usually we have to download the
        // last months worth or more (takes a few seconds).
        try {
            walletAppKit.setCheckpoints(getClass().getResourceAsStream("/wallet/checkpoints"));
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.toString());
        }
    } else if (params == TestNet3Params.get()) {
        walletAppKit.setCheckpoints(getClass().getResourceAsStream("/wallet/checkpoints.testnet"));
    }

    // If operating over a proxy and we haven't set any peer nodes, then
    // we want to use SeedPeers for discovery instead of the default DnsDiscovery.
    // This is only because we do not yet have a Dns discovery class that works
    // reliably over proxy/tor.
    //
    // todo: There should be a user pref called "Use Local DNS for Proxy/Tor"
    // that disables this.  In that case, the default DnsDiscovery class will
    // be used which should work, but is less private.  The aim here is to
    // be private by default when using proxy/tor.  However, the seedpeers
    // could become outdated, so it is important that the user be able to
    // disable it, but should be made aware of the reduced privacy.
    if (socks5Proxy != null && !usePeerNodes) {
        // SeedPeers uses hard coded stable addresses (from MainNetParams). It should be updated from time to time.
        walletAppKit.setDiscovery(new Socks5MultiDiscovery(socks5Proxy, params, socks5DiscoverMode));
    }

    walletAppKit.setDownloadListener(downloadListener).setBlockingStartup(false)
            .setUserAgent(userAgent.getName(), userAgent.getVersion()).restoreWalletFromSeed(seed);

    walletAppKit.addListener(new Service.Listener() {
        @Override
        public void failed(@NotNull Service.State from, @NotNull Throwable failure) {
            walletAppKit = null;
            log.error("walletAppKit failed");
            timeoutTimer.stop();
            UserThread.execute(() -> exceptionHandler.handleException(failure));
        }
    }, Threading.USER_THREAD);
    walletAppKit.startAsync();
}

From source file:com.ericsson.eiffel.remrem.semantics.SemanticsService.java

@Override
public String generateRoutingKey(JsonObject eiffelMessage, String tag, String domain, String userDomainSuffix) {
    String family = getFamily(eiffelMessage);
    String type = getType(eiffelMessage);
    if (StringUtils.isNotEmpty(family) && StringUtils.isNotEmpty(type)) {
        if (StringUtils.isNotBlank(tag)
                && (tag.contains(".") || StringUtils.deleteWhitespace(tag).length() > 16)) {
            log.error("tag must not contain any dots and must not exceed 16 characters");
            return null;
        }/*from   ww w .jav a  2s.  c  om*/
        String domainId = getDomainId(eiffelMessage);
        // If domainId from input message is null then configured domain
        // will be considered
        domainId = StringUtils.defaultIfBlank(domainId, domain);
        if (StringUtils.isNotBlank(domainId)) {
            if (StringUtils.isNotBlank(userDomainSuffix)) {
                domainId = domainId + DOT + userDomainSuffix;
            }
            return StringUtils.deleteWhitespace(PROTOCOL + DOT + family + DOT + type + DOT
                    + StringUtils.defaultIfBlank(tag, "notag") + DOT + domainId);
        }
        log.error(
                "domain needed for Routing key generation in the format <protocol>.<family>.<type>.<tag>.<domain> is not provided in either input message or configuration");
    }
    return null;
}

From source file:com.alliander.osgp.acceptancetests.configurationmanagement.GetConfigurationDataSteps.java

@DomainStep("the get configuration response should contain: (.*), (.*), (.*), (.*), (.*), (.*), (.*), (.*), (.*) and (.*)")
public boolean thenTheResponseShouldContain(final String lightType, final String dcLights, final String dcMap,
        final String rcType, final String rcMap, final String shortInterval, final String preferredLinkType,
        final String meterType, final String longInterval, final String longIntervalType) {
    LOGGER.info("THEN: the get configuration response should return {}, {}, {}, {}, {}, {}, {}, {}, {} and {}.",
            new Object[] { lightType, dcLights, dcMap, rcType, rcMap, shortInterval, preferredLinkType,
                    meterType, longInterval, longIntervalType });

    try {//  w ww .  j a v  a2  s  . com
        Assert.assertNotNull("Response should not be null", this.response);
        Assert.assertNull("Throwable should be null", this.throwable);

        final Configuration configuration = this.response.getConfiguration();

        Assert.assertNotNull("Configuration should not be null", configuration);

        // light type
        Assert.assertEquals("Light type should equal expected value", lightType.trim(),
                configuration.getLightType() != null ? configuration.getLightType().name() : "");

        // dali configuration
        if (configuration.getLightType() == LightType.DALI
                && (StringUtils.isNotBlank(dcLights) || StringUtils.isNotBlank(dcMap))) {

            final DaliConfiguration daliConfiguration = configuration.getDaliConfiguration();

            Assert.assertNotNull("Dali configuration should not be null", daliConfiguration);

            // lights
            Assert.assertEquals("Dali configuration lights should equal expected value",
                    StringUtils.isNotBlank(dcLights.trim()) ? Integer.parseInt(dcLights.trim()) : 0,
                    daliConfiguration.getNumberOfLights());

            // index address map
            Assert.assertNotNull("Index address map should not be null",
                    daliConfiguration.getIndexAddressMap());
            Assert.assertEquals("Index address map should equal expected value",
                    StringUtils.deleteWhitespace(dcMap),
                    this.convertIndexAddressMapToString(daliConfiguration.getIndexAddressMap()));
        }

        // relay configuration
        if (configuration.getLightType() == LightType.RELAY && StringUtils.isNotBlank(rcType)
                && StringUtils.isNotBlank(rcMap)) {

            final RelayConfiguration relayConfiguration = configuration.getRelayConfiguration();

            Assert.assertNotNull("Relay configuration should not be null", relayConfiguration);

            // Type
            Assert.assertEquals("Relay type should equal expected value", rcType,
                    (relayConfiguration.getRelayMap().get(0).getRelayType().value()));

            // Relay map
            Assert.assertEquals("Relay map should equal expected value", StringUtils.deleteWhitespace(rcMap),
                    this.convertRelayMapToString(relayConfiguration.getRelayMap()));
        }

        // shortInterval
        Assert.assertEquals("Short interval should equal expected value",
                StringUtils.isBlank(shortInterval) ? null : Integer.parseInt(shortInterval.trim()),
                configuration.getShortTermHistoryIntervalMinutes());

        // preferredLinkType
        Assert.assertEquals("Preferred link type should equal expected value", preferredLinkType.trim(),
                configuration.getPreferredLinkType() != null ? configuration.getPreferredLinkType().value()
                        : "");

        // meterType
        Assert.assertEquals("Meter type should equal expected value", meterType.trim(),
                configuration.getMeterType() != null ? configuration.getMeterType().value() : "");

        // longInterval
        Assert.assertEquals("Long interval should equal expected value",
                StringUtils.isBlank(longInterval) ? null : Integer.parseInt(longInterval.trim()),
                configuration.getLongTermHistoryInterval());

        // longIntervalType
        Assert.assertEquals("Long interval type should equal expected value", longIntervalType.trim(),
                configuration.getLongTermHistoryIntervalType() != null
                        ? configuration.getLongTermHistoryIntervalType().value()
                        : "");
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }

    return true;
}

From source file:com.alliander.osgp.acceptancetests.configurationmanagement.GetConfigurationDataSteps.java

@DomainStep("the get get configuration response request should return a get configuration response with result (.*) and description (.*), (.*), (.*), (.*), (.*), (.*), (.*), (.*), (.*), (.*), (.*)")
public boolean thenTheResponseShouldContain(final String result, final String description,
        final String lightType, final String dcLights, final String dcMap, final String rcType,
        final String rcMap, final String shortInterval, final String preferredLinkType, final String meterType,
        final String longInterval, final String longIntervalType) {

    LOGGER.info(//from   w ww.  j  a  va 2  s .c  o m
            "THEN: the get get configuration response request should return a get configuration response with result {} .",
            result);

    try {
        if ("NOT_OK".equals(result)) {
            Assert.assertNull("Set Schedule Response should be null", this.response);
            Assert.assertNotNull("Throwable should not be null", this.throwable);
            Assert.assertTrue("Throwable should contain a validation exception",
                    this.throwable.getCause() instanceof ValidationException);
        } else {

            Assert.assertNotNull("Response should not be null", this.response);

            // Check the result.
            final String expected = result.equals("NULL") ? null : result;
            final String actual = this.response.getResult().toString();

            Assert.assertTrue("Invalid result, found: " + actual + " , expected: " + expected,
                    actual.equals(expected));

            if (this.response.getResult().equals("OK")) {

                Assert.assertNotNull("Configuration is null", this.response.getConfiguration());

                // light type
                Assert.assertEquals("Light type should equal expected value", lightType.trim(),
                        this.response.getConfiguration().getLightType() != null
                                ? this.response.getConfiguration().getLightType().name()
                                : "");

                // dali configuration
                if (this.response.getConfiguration().getLightType() == LightType.DALI
                        && (StringUtils.isNotBlank(dcLights) || StringUtils.isNotBlank(dcMap))) {

                    final DaliConfiguration daliConfiguration = this.response.getConfiguration()
                            .getDaliConfiguration();

                    Assert.assertNotNull("Dali configuration should not be null", daliConfiguration);

                    // lights
                    Assert.assertEquals("Dali configuration lights should equal expected value",
                            StringUtils.isNotBlank(dcLights.trim()) ? Integer.parseInt(dcLights.trim()) : 0,
                            daliConfiguration.getNumberOfLights());

                    // index address map
                    Assert.assertNotNull("Index address map should not be null",
                            daliConfiguration.getIndexAddressMap());
                    Assert.assertEquals("Index address map should equal expected value",
                            StringUtils.deleteWhitespace(dcMap),
                            this.convertIndexAddressMapToString(daliConfiguration.getIndexAddressMap()));
                }

                // relay configuration
                if (this.response.getConfiguration().getLightType() == LightType.RELAY
                        && StringUtils.isNotBlank(rcType) && StringUtils.isNotBlank(rcMap)) {

                    final RelayConfiguration relayConfiguration = this.response.getConfiguration()
                            .getRelayConfiguration();

                    Assert.assertNotNull("Relay configuration should not be null", relayConfiguration);

                    // Type

                    Assert.assertEquals("Relay type should equal expected value", rcType,
                            (relayConfiguration.getRelayMap().get(0).getRelayType().value()));

                    // Relay map
                    Assert.assertEquals("Relay map should equal expected value",
                            StringUtils.deleteWhitespace(rcMap),
                            this.convertRelayMapToString(relayConfiguration.getRelayMap()));
                }

                // shortInterval
                Assert.assertEquals("Short interval should equal expected value",
                        StringUtils.isBlank(shortInterval) ? null : Integer.parseInt(shortInterval.trim()),
                        this.response.getConfiguration().getShortTermHistoryIntervalMinutes());

                // preferredLinkType
                Assert.assertEquals("Preferred link type should equal expected value", preferredLinkType.trim(),
                        this.response.getConfiguration().getPreferredLinkType() != null
                                ? this.response.getConfiguration().getPreferredLinkType().value()
                                : "");

                // meterType
                Assert.assertEquals("Meter type should equal expected value", meterType.trim(),
                        this.response.getConfiguration().getMeterType() != null
                                ? this.response.getConfiguration().getMeterType().value()
                                : "");

                // longInterval
                Assert.assertEquals("Long interval should equal expected value",
                        StringUtils.isBlank(longInterval) ? null : Integer.parseInt(longInterval.trim()),
                        this.response.getConfiguration().getLongTermHistoryInterval());

                // longIntervalType
                Assert.assertEquals("Long interval type should equal expected value", longIntervalType.trim(),
                        this.response.getConfiguration().getLongTermHistoryIntervalType() != null
                                ? this.response.getConfiguration().getLongTermHistoryIntervalType().value()
                                : "");
            }
        }
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }

    return true;
}

From source file:com.quinsoft.zeidon.vml.VmlOperation.java

protected static final int zRemoveAllBlanks(String courseNumberIn, StringBuilder sbCourseNumberOut,
        int maxLth) {
    sbCourseNumberOut.setLength(0); // Use sb.setLength( 0 ); to clear a string buffer.
    sbCourseNumberOut.append(StringUtils.deleteWhitespace(courseNumberIn));
    return 0;/*from  ww  w  .j a v a  2  s .c o  m*/
}

From source file:objenome.util.ClassUtils.java

/**
 * Converts a class name to a JLS style class name.
 *
 * @param className  the class name/*from w  w  w .  ja v  a 2s  . co m*/
 * @return the converted name
 */
private static String toCanonicalName(String className) {
    className = StringUtils.deleteWhitespace(className);
    if (className == null) {
        throw new NullPointerException("className must not be null.");
    }
    if (className.endsWith("[]")) {
        StringBuilder classNameBuffer = new StringBuilder();
        while (className.endsWith("[]")) {
            className = className.substring(0, className.length() - 2);
            classNameBuffer.append('[');
        }
        String abbreviation = abbreviationMap.get(className);
        if (abbreviation != null) {
            classNameBuffer.append(abbreviation);
        } else {
            classNameBuffer.append('L').append(className).append(';');
        }
        className = classNameBuffer.toString();
    }
    return className;
}

From source file:objenome.util.ClassUtils.java

/**
 * <p>Converts a given name of class into canonical format.
 * If name of class is not a name of array class it returns
 * unchanged name.</p>//from   w w w  .j av  a 2  s. c o  m
 * <p>Example:
 * <ul>
 * <li>{@code getCanonicalName("[I") = "int[]"}</li>
 * <li>{@code getCanonicalName("[Ljava.lang.String;") = "java.lang.String[]"}</li>
 * <li>{@code getCanonicalName("java.lang.String") = "java.lang.String"}</li>
 * </ul>
 * </p>
 *
 * @param className the name of class
 * @return canonical form of class name
 * @since 2.4
 */
private static String getCanonicalName(String className) {
    className = StringUtils.deleteWhitespace(className);
    if (className == null) {
        return null;
    }
    int dim = 0;
    while (className.length() > 0 && className.charAt(0) == '[') {
        dim++;
        className = className.substring(1);
    }
    if (dim < 1) {
        return className;
    }
    if (className.length() > 0 && className.charAt(0) == 'L') {
        className = className.substring(1,
                className.length() > 0 && className.charAt(className.length() - 1) == ';'
                        ? className.length() - 1
                        : className.length());
    } else {
        if (!className.isEmpty()) {
            className = reverseAbbreviationMap.get(className.substring(0, 1));
        }
    }
    StringBuilder canonicalClassNameBuffer = new StringBuilder(className);
    for (int i = 0; i < dim; i++) {
        canonicalClassNameBuffer.append("[]");
    }
    return canonicalClassNameBuffer.toString();
}