Java Code Examples for org.netbeans.modules.php.api.util.StringUtils#explode()

The following examples show how to use org.netbeans.modules.php.api.util.StringUtils#explode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemoteUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Get parent path for the given path.
 * @param path file path
 * @return parent path or "/" for absolute top-level path
 * or {@code null} if parent path does not exist
 */
public static String getParentPath(String path) {
    if (path.equals(TransferFile.REMOTE_PATH_SEPARATOR)) {
        return null;
    }
    boolean absolute = path.startsWith(TransferFile.REMOTE_PATH_SEPARATOR);
    if (absolute) {
        path = path.substring(1);
    }
    String parent;
    List<String> parts = new ArrayList<>(StringUtils.explode(path, TransferFile.REMOTE_PATH_SEPARATOR));
    if (parts.size() <= 1) {
        return absolute ? TransferFile.REMOTE_PATH_SEPARATOR : null;
    }
    parts.remove(parts.size() - 1);
    parent = StringUtils.implode(parts, TransferFile.REMOTE_PATH_SEPARATOR);
    if (absolute) {
        return TransferFile.REMOTE_PATH_SEPARATOR + parent;
    }
    return parent;
}
 
Example 2
Source File: CommandUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static String encodeRelativeUrl(String relativeUrl) {
    if (!StringUtils.hasText(relativeUrl)) {
        return relativeUrl;
    }
    StringBuilder sb = new StringBuilder(relativeUrl.length() * 2);
    try {
        for (String part : StringUtils.explode(relativeUrl, "/")) { // NOI18N
            if (sb.length() > 0) {
                sb.append('/'); // NOI18N
            }
            sb.append(URLEncoder.encode(part, "UTF-8")); // NOI18N
        }
    } catch (UnsupportedEncodingException ex) {
        Exceptions.printStackTrace(ex);
        return relativeUrl;
    }
    return sb.toString();
}
 
Example 3
Source File: RunAsWebAdvanced.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Object[][] getPathMappings(String remotePaths, String localPaths) {
    List<String> remotes = StringUtils.explode(remotePaths, PhpProjectProperties.DEBUG_PATH_MAPPING_SEPARATOR);
    List<String> locals = StringUtils.explode(localPaths, PhpProjectProperties.DEBUG_PATH_MAPPING_SEPARATOR);
    int remotesSize = remotes.size();
    int localsSize = locals.size();
    Object[][] paths = new Object[remotesSize + 1][2];
    for (int i = 0; i < remotesSize; ++i) {
        // if user has only 1 path and local == sources => property is not stored at all!
        String local = DEFAULT_LOCAL_PATH;
        if (i < localsSize) {
            local = locals.get(i);
        }
        Pair<String, String> pathMapping = getPathMapping(remotes.get(i), local);
        paths[i][COLUMN_REMOTE_PATH] = pathMapping.first();
        paths[i][COLUMN_LOCAL_PATH] = new LocalPathCell(pathMapping.second());
    }
    paths[remotesSize][COLUMN_REMOTE_PATH] = null;
    paths[remotesSize][COLUMN_LOCAL_PATH] = new LocalPathCell(DEFAULT_LOCAL_PATH);
    return paths;
}
 
Example 4
Source File: CakePHP3Options.java    From cakephp3-netbeans with Apache License 2.0 5 votes vote down vote up
public List<String> getAvailableCustomNodes() {
    String nodes = getPreferences().get(AVAILABLE_CUSTOM_NODES, null);
    if (nodes == null) {
        return DEFAULT_AVAILABLE_NODES;
    }
    return StringUtils.explode(nodes, "|"); // NOI18N
}
 
Example 5
Source File: ApiGenPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private List<String> getExcludes() {
    String excludes = excludesTextField.getText().trim();
    if (StringUtils.hasText(excludes)) {
        return StringUtils.explode(excludes, SEPARATOR);
    }
    return Collections.emptyList();
}
 
Example 6
Source File: ApiGenPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private List<String> getCharsets() {
    String charsets = charsetsTextField.getText().trim();
    if (StringUtils.hasText(charsets)) {
        return StringUtils.explode(charsets, SEPARATOR);
    }
    return Collections.emptyList();
}
 
Example 7
Source File: UserAnnotations.java    From netbeans with Apache License 2.0 5 votes vote down vote up
EnumSet<UserAnnotationTag.Type> unmarshallTypes(String types) {
    List<String> list = StringUtils.explode(types, DELIMITER);
    EnumSet<UserAnnotationTag.Type> result = EnumSet.noneOf(UserAnnotationTag.Type.class);
    for (String type : list) {
        result.add(UserAnnotationTag.Type.valueOf(type));
    }
    return result;
}
 
Example 8
Source File: PhpProjectProperties.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public List<String> getTestingProviders() {
    if (testingProviders == null) {
        String value = ProjectPropertiesSupport.getPropertyEvaluator(project).getProperty(TESTING_PROVIDERS);
        testingProviders = StringUtils.explode(value, TESTING_PROVIDERS_SEPARATOR);
    }
    return testingProviders;
}
 
Example 9
Source File: RemoteUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Get name of the file for the given path.
 * @param path file path
 * @return name of the file for the given path
 */
public static String getName(String path) {
    if (path.equals(TransferFile.REMOTE_PATH_SEPARATOR)) {
        return TransferFile.REMOTE_PATH_SEPARATOR;
    }
    List<String> parts = new ArrayList<>(StringUtils.explode(path, TransferFile.REMOTE_PATH_SEPARATOR));
    return parts.get(parts.size() - 1);
}
 
Example 10
Source File: DiffPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String getExtension(String filename) {
    List<String> parts = StringUtils.explode(filename, "."); // NOI18N
    if (parts.isEmpty()) {
        return null;
    }
    return parts.get(parts.size() - 1);
}
 
Example 11
Source File: TransferFile.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Get remote (platform independent) path of the parent file
 * or throws an exception if the file is {@link #isProjectRoot() project root}.
 * <p>
 * This method can be used to get parent directory even if {@link #getParent() parent}
 * is not set.
 * @return remote path of the parent file
 * @see #getRemotePath()
 */
public final String getParentRemotePath() {
    if (getParent() != null) {
        return getParent().getRemotePath();
    }
    List<String> fragments = new ArrayList<>(StringUtils.explode(getRemotePath(), REMOTE_PATH_SEPARATOR));
    fragments.remove(fragments.size() - 1);
    if (fragments.isEmpty()) {
        return REMOTE_PROJECT_ROOT;
    }
    return StringUtils.implode(fragments, REMOTE_PATH_SEPARATOR);
}
 
Example 12
Source File: ProjectPropertiesSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * @return list of pairs of remote path (as a String) and local path (absolute path, as a String); empty remote paths are skipped
 *         as well as invalid local paths
 */
public static List<Pair<String, String>> getDebugPathMapping(PhpProject project) {
    List<String> remotes = StringUtils.explode(
            getString(project, PhpProjectProperties.DEBUG_PATH_MAPPING_REMOTE, null), PhpProjectProperties.DEBUG_PATH_MAPPING_SEPARATOR);
    List<String> locals = StringUtils.explode(
            getString(project, PhpProjectProperties.DEBUG_PATH_MAPPING_LOCAL, null), PhpProjectProperties.DEBUG_PATH_MAPPING_SEPARATOR);
    int remotesSize = remotes.size();
    int localsSize = locals.size();
    List<Pair<String, String>> paths = new ArrayList<>(remotesSize);
    for (int i = 0; i < remotesSize; ++i) {
        String remotePath = remotes.get(i);
        if (StringUtils.hasText(remotePath)) {
            // if user has only 1 path and local == sources => property is not stored at all!
            String l = ""; // NOI18N
            if (i < localsSize) {
                l = locals.get(i);
            }
            String localPath = null;
            File local = new File(l);
            if (local.isAbsolute()) {
                if (local.isDirectory()) {
                    localPath = local.getAbsolutePath();
                }
            } else {
                File subDir = getSourceSubdirectory(project, l);
                if (subDir.exists()) {
                    localPath = subDir.getAbsolutePath();
                }
            }

            if (localPath != null) {
                paths.add(Pair.of(remotePath, localPath));
            }
        }
    }
    Pair<String, String> copySupportPair = getCopySupportPair(project);
    if (copySupportPair != null) {
        paths.add(copySupportPair);
    }
    return paths;
}
 
Example 13
Source File: PhpUnitPreferences.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static List<String> getTestGroups(PhpModule phpModule) {
    return StringUtils.explode(getPreferences(phpModule).get(TEST_GROUPS, null), TEST_GROUPS_DELIMITER);
}
 
Example 14
Source File: AnalysisUtils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static List<String> deserialize(String input) {
    return StringUtils.explode(input, SERIALIZE_DELIMITER);
}
 
Example 15
Source File: ApiGenPreferences.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static List<String> getMore(PhpModule phpModule, Property<? extends Object> property) {
    return StringUtils.explode(get(phpModule, property), SEPARATOR);
}
 
Example 16
Source File: DependenciesPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static List<String> getVersions(String versionsLine) {
    List<String> versions = new ArrayList<>(StringUtils.explode(versionsLine, VERSIONS_DELIMITER));
    versions.add("*"); // NOI18N
    return versions;
}
 
Example 17
Source File: ProjectSettings.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public static List<String> getDebugUrls(Project project) {
    return StringUtils.explode(getPreferences(project).get(DEBUG_URLS, null), DEBUG_URLS_DELIMITER);
}