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

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

Introduction

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

Prototype

public static boolean endsWith(final CharSequence str, final CharSequence suffix) 

Source Link

Document

Check if a CharSequence ends with a specified suffix.

null s are handled without exceptions.

Usage

From source file:rs.metropolitan.data_changer.lists.ToList.java

@Override
public ArrayList<String> changeString(String data) {
    String left = "{";
    String right = "}";
    String doubleQuote = "\"";
    String seps = ",";
    if (StringUtils.startsWith(data, left) && StringUtils.endsWith(data, right)) {
        String cleaned = StringUtils.remove(data, left);
        cleaned = StringUtils.remove(cleaned, right);
        cleaned = StringUtils.remove(cleaned, doubleQuote);
        System.out.println(cleaned);
        StringTokenizer st = new StringTokenizer(cleaned, seps);
        while (st.hasMoreTokens()) {
            ArraylistString.add(st.nextToken());
        }//w  ww .ja va 2  s .  c om
    }
    return ArraylistString;
}

From source file:samples.ObjectPredicator.java

public static <T extends CharSequence> Predicate<T> endsWith(final CharSequence suffix) {
    return t -> StringUtils.endsWith(t, suffix);
}

From source file:syncthing.android.App.java

boolean isServiceProcess() {
    readProcess();
    return StringUtils.endsWith(mProcess, ":service");
}

From source file:syncthing.android.service.SyncthingUtils.java

public static File[] listExportedConfigs(Context context) {
    File root = Environment.getExternalStorageDirectory();
    return root/*from ww w.j  av a 2  s  .co  m*/
            .listFiles((dir, filename) -> StringUtils.startsWith(filename, context.getPackageName() + "-export")
                    && StringUtils.endsWith(filename, ".zip"));
}

From source file:syncthing.android.service.SyncthingUtils.java

public static String buildUrl(@NonNull String host, @NonNull String port, boolean tls) {
    host = stripHttp(StringUtils.trim(host).toLowerCase(Locale.US));
    port = StringUtils.strip(StringUtils.trim(port), ":");
    String path = "";
    if (isDomainNameWithPath(host)) {
        path = Uri.parse("http://" + host).getPath();
        host = StringUtils.remove(host, path);
    }//from w  w w. j  a  v a 2s .c o  m
    return (tls ? "https://" : "http://") + host + ":" + port +
    //without the trailing slash retrofit wont build the url correctly
            ((StringUtils.isEmpty(path) || StringUtils.endsWith(path, "/")) ? path : (path + "/"));
}

From source file:syncthing.android.ui.folderpicker.FolderPickerPresenter.java

@Inject
public FolderPickerPresenter(Credentials credentials, @Named("path") String path, SessionManager sessionManager,
        FragmentManagerOwner fm, ActivityResultsController activityResultsController,
        DialogPresenter dialogPresenter) {
    this.credentials = credentials;
    this.path = StringUtils.endsWith(path, "/") ? path : path + "/";
    this.sessionManager = sessionManager;
    this.session = sessionManager.acquire(credentials);
    this.fm = fm;
    this.activityResultsController = activityResultsController;
    this.dialogPresenter = dialogPresenter;
}

From source file:syncthing.android.ui.folderpicker.FolderPickerViewAdapter.java

private static String getBaseName(String path) {
    if (StringUtils.endsWith(path, "/")) {
        path = path.substring(0, path.length() - 1);
    }/*from  w w w  .j av  a2s .  c om*/
    int lastSlash = path.lastIndexOf("/");
    if (lastSlash >= 0 && lastSlash < path.length()) {
        return path.substring(lastSlash + 1);
    }
    return path;
}

From source file:syncthing.android.ui.sessionsettings.EditFolderPresenter.java

public void openFolderPicker(View btn) {
    String path = getFolderPath();
    if (StringUtils.endsWith(path, "/")) {
        path = path.substring(0, path.length() - 1);
    } else if (path.lastIndexOf("/") > 0) {
        //we want the last directory they inputed not any partial name in there
        path = path.substring(0, path.lastIndexOf("/"));
    }/*from  w w  w. ja v  a2 s . c o  m*/
    Intent i = new Intent(btn.getContext(), ManageActivity.class)
            .putExtra(ManageActivity.EXTRA_FRAGMENT, FolderPickerFragment.NAME)
            .putExtra(ManageActivity.EXTRA_ARGS, FolderPickerFragment.makeArgs(credentials, path))
            .putExtra(ManageActivity.EXTRA_UP_IS_BACK, true);
    activityResultsController.startActivityForResult(i, ActivityRequestCodes.FOLDER_PICKER, null);
}

From source file:us.fatehi.pointlocation6709.parse.PointLocationParser.java

/**
 * Parses a string representation of the point location.
 *
 * @param representation//from   www .j  a  v  a 2 s  .c o m
 *        String representation of the point location
 * @return Point location
 * @throws ParserException
 *         On an exception
 */
public static PointLocation parsePointLocation(final String representation) throws ParserException {
    if (StringUtils.isBlank(representation)) {
        throw new ParserException("No point location value provided");
    }
    if (!StringUtils.endsWith(representation, "/")) {
        throw new ParserException("Point location value must be terminated with /");
    }

    final PointLocationParser parser = new PointLocationParser();
    final CoordinateParser coordinateParser = new CoordinateParser();
    // Split by group
    final List<String> tokens = parser.split(representation);
    if (tokens.size() != 4) {
        throw new ParserException("Cannot parse " + representation);
    }

    final Latitude latitude = coordinateParser.parseLatitude(tokens.get(0));
    final Longitude longitude = coordinateParser.parseLongitude(tokens.get(1));
    final double altitude = NumberUtils.toDouble(tokens.get(2));
    final String coordinateReferenceSystemIdentifier = StringUtils.trimToEmpty(tokens.get(3));

    final PointLocation pointLocation = new PointLocation(latitude, longitude, altitude,
            coordinateReferenceSystemIdentifier);
    return pointLocation;
}