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

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

Introduction

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

Prototype

public static String reverseDelimited(String str, char separatorChar) 

Source Link

Document

Reverses a String that is delimited by a specific character.

Usage

From source file:Main.java

public static void main(String[] args) {
    String words = "The quick brown fox jumps over the lazy dog";

    String reversed = StringUtils.reverse(words);

    String delimitedReverse = StringUtils.reverseDelimited(words, ' ');

    System.out.println("Original: " + words);
    System.out.println("Reversed: " + reversed);
    System.out.println("Delimited Reverse: " + delimitedReverse);
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.common.BoundingBoxReader.java

/**
 * @param coords//  w ww . j av  a2 s  .co  m
 *            The latitude and longitude coordinates (in no particular order).
 * @param axisOrder
 *            The order that the axes are represented.
 * @return The coordinates in LON/LAT order.
 */
private String[] getCoordinates(String coords, CswAxisOrder axisOrder) {

    switch (axisOrder) {
    case LAT_LON: {
        /**
         * We want to create WKT in LON/LAT order. Since the response has the coords in LAT/LON
         * order, we need to reverse them.
         */
        return StringUtils.reverseDelimited(coords, SPACE.charAt(0)).split(SPACE);
    }
    default: {
        /**
         * We want to create WKT in LON/LAT order. Since this is the order of the coords in the
         * response, we use them as-is.
         */
        return coords.split(SPACE);
    }
    }
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.common.source.CswFilterFactory.java

/**
 * The WKT passed into the spatial methods has the coordinates ordered in LON/LAT. This method
 * will convert the WKT to LAT/LON ordering.
 */// w  ww  . ja  v a2s  .  c om
private String convertWktToLatLonOrdering(String wktInLonLat) {

    if (cswAxisOrder != CswAxisOrder.LON_LAT) {
        LOGGER.debug("Converting WKT from LON/LAT coordinate ordering to LAT/LON coordinate ordering.");

        // Normalize all whitespace in WKT before processing.
        wktInLonLat = normalizeWhitespaceInWkt(wktInLonLat);

        Matcher matcher = COORD_PATTERN.matcher(wktInLonLat);

        StringBuffer stringBuffer = new StringBuffer();

        while (matcher.find()) {
            String lonLatCoord = matcher.group();
            String latLonCoord = StringUtils.reverseDelimited(lonLatCoord, ' ');
            LOGGER.debug("Converted LON/LAT coord: ({}) to LAT/LON coord: ({}).", lonLatCoord, latLonCoord);
            matcher.appendReplacement(stringBuffer, latLonCoord);
        }

        matcher.appendTail(stringBuffer);

        String wktInLatLon = stringBuffer.toString();
        LOGGER.debug("Original WKT with coords in LON/LAT ordering:  {}", wktInLonLat);
        LOGGER.debug("Converted WKT with coords in LAT/LON ordering: {}", wktInLatLon);

        return wktInLatLon;
    } else {
        LOGGER.debug("The configured CSW source requires coordinates in LON/LAT ordering.");
        return wktInLonLat;
    }
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.source.CswFilterFactory.java

/**
 * The WKT passed into the spatial methods has the coordinates ordered in LON/LAT. This method
 * will convert the WKT to LAT/LON ordering.
 *///from  ww  w.  j a  v a 2 s .c  om
private String convertWktToLatLonOrdering(String wktInLonLat) {

    if (!isLonLatOrder) {
        LOGGER.debug("Converting WKT from LON/LAT coordinate ordering to LAT/LON coordinate ordering.");

        // Normalize all whitespace in WKT before processing.
        wktInLonLat = normalizeWhitespaceInWkt(wktInLonLat);

        Matcher matcher = COORD_PATTERN.matcher(wktInLonLat);

        StringBuffer stringBuffer = new StringBuffer();

        while (matcher.find()) {
            String lonLatCoord = matcher.group();
            String latLonCoord = StringUtils.reverseDelimited(lonLatCoord, ' ');
            LOGGER.debug("Converted LON/LAT coord: ({}) to LAT/LON coord: ({}).", lonLatCoord, latLonCoord);
            matcher.appendReplacement(stringBuffer, latLonCoord);
        }

        matcher.appendTail(stringBuffer);

        String wktInLatLon = stringBuffer.toString();
        LOGGER.debug("Original WKT with coords in LON/LAT ordering:  {}", wktInLonLat);
        LOGGER.debug("Converted WKT with coords in LAT/LON ordering: {}", wktInLatLon);

        return wktInLatLon;
    } else {
        LOGGER.debug("The configured CSW source requires coordinates in LON/LAT ordering.");
        return wktInLonLat;
    }
}

From source file:org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.source.WfsFilterDelegate.java

/**
 * The WKT passed into the spatial methods has the coordinates ordered in LON/LAT. This method
 * will convert the WKT to LAT/LON ordering.
 *///from  w w  w  .  j av  a 2  s.  co m
private String convertWktToLatLonOrdering(String wktInLonLat) {

    if (Wfs20Constants.LAT_LON_ORDER.equals(coordinateOrder)) {
        LOGGER.debug("Converting WKT from LON/LAT coordinate ordering to LAT/LON coordinate ordering.");

        // Normalize all whitespace in WKT before processing.
        wktInLonLat = normalizeWhitespaceInWkt(wktInLonLat);

        Matcher matcher = COORD_PATTERN.matcher(wktInLonLat);

        StringBuffer stringBuffer = new StringBuffer();

        while (matcher.find()) {
            String lonLatCoord = matcher.group();
            String latLonCoord = StringUtils.reverseDelimited(lonLatCoord, ' ');
            LOGGER.debug("Converted LON/LAT coord: ({}) to LAT/LON coord: ({}).", lonLatCoord, latLonCoord);
            matcher.appendReplacement(stringBuffer, latLonCoord);
        }

        matcher.appendTail(stringBuffer);

        String wktInLatLon = stringBuffer.toString();
        LOGGER.debug("Original WKT with coords in LON/LAT ordering:  {}", wktInLonLat);
        LOGGER.debug("Converted WKT with coords in LAT/LON ordering: {}", wktInLatLon);

        return wktInLatLon;
    } else {
        LOGGER.debug("The configured CSW source requires coordinates in LON/LAT ordering.");
        return wktInLonLat;
    }
}