本文整理汇总了Java中org.netbeans.spi.project.support.ant.PropertyUtils类的典型用法代码示例。如果您正苦于以下问题:Java PropertyUtils类的具体用法?Java PropertyUtils怎么用?Java PropertyUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyUtils类属于org.netbeans.spi.project.support.ant包,在下文中一共展示了PropertyUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeFromPath
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
/**
* Removes the path entry from path.
* @param path to remove the netry from
* @param toRemove the entry to be rmeoved from the path
* @return new path with removed entry
*/
@NonNull
public static String removeFromPath(@NonNull final String path, @NonNull final String toRemove) {
Parameters.notNull("path", path); //NOI18N
Parameters.notNull("toRemove", toRemove); //NOI18N
final StringBuilder sb = new StringBuilder();
for (String entry : PropertyUtils.tokenizePath(path)) {
if (toRemove.equals(entry)) {
continue;
}
sb.append(entry);
sb.append(':'); //NOI18N
}
return sb.length() == 0 ?
sb.toString() :
sb.substring(0, sb.length()-1);
}
示例2: remove
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
private void remove(@NonNull final AntProjectHelper helper) {
final EditableProperties props = helper.getProperties (AntProjectHelper.PROJECT_PROPERTIES_PATH);
String rawPath = props.getProperty (classPathId);
if (rawPath != null) {
final String[] pathElements = PropertyUtils.tokenizePath(rawPath);
final List<String> result = new ArrayList<String>(pathElements.length);
boolean changed = false;
for (String pathElement : pathElements) {
if (rawId.equals(pathElement)) {
changed = true;
continue;
}
result.add(pathElement + PATH_SEPARATOR_CHAR);
}
if (!result.isEmpty()) {
final String last = result.get(result.size()-1);
result.set(result.size()-1, last.substring(0, last.length()-1));
}
if (changed) {
props.setProperty(classPathId, result.toArray(new String[result.size()]));
helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
}
}
}
示例3: isValidPanel
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
@Messages({
"WARN_MakeSharable.absolutePath=<html>Please make sure that the absolute path in the Libraries Folder field is valid for all users.<html>",
"WARN_makeSharable.relativePath=<html>Please make sure that the relative path in the Libraries Folder field is valid for all users.<html>"
})
boolean isValidPanel() {
String location = getLibraryLocation();
boolean wrong = false;
if (new File(location).isAbsolute()) {
settings.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, WARN_MakeSharable_absolutePath());
wrong = true;
} else {
File projectLoc = FileUtil.toFile(helper.getProjectDirectory());
File libLoc = PropertyUtils.resolveFile(projectLoc, location);
if (!CollocationQuery.areCollocated(projectLoc, libLoc)) {
settings.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, WARN_makeSharable_relativePath());
wrong = true;
}
}
if (!wrong) {
settings.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, null);
}
return true;
}
示例4: removeNBArtifacts
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
public static String removeNBArtifacts(
@NonNull final String key,
@NullAllowed String value) {
if (value != null && "java.class.path".equals(key)) { //NOI18N
String nbHome = System.getProperty("netbeans.home"); //NOI18N
if (nbHome != null) {
if (!nbHome.endsWith(File.separator)) {
nbHome = nbHome + File.separatorChar;
}
final String[] elements = PropertyUtils.tokenizePath(value);
final List<String> newElements = new ArrayList<>(elements.length);
for (String element : elements) {
if (!element.startsWith(nbHome)) {
newElements.add(element);
}
}
if (elements.length != newElements.size()) {
value = newElements.stream()
.collect(Collectors.joining(File.pathSeparator));
}
}
}
return value;
}
示例5: filterProbe
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
private static String filterProbe (String v, final String probePath) {
if (v != null) {
final String[] pes = PropertyUtils.tokenizePath(v);
final StringBuilder sb = new StringBuilder ();
for (String pe : pes) {
if (probePath != null ? probePath.equals(pe) : (pe != null &&
pe.endsWith("org-netbeans-modules-java-j2seplatform-probe.jar"))) { //NOI18N
//Skeep
}
else {
if (sb.length() > 0) {
sb.append(File.pathSeparatorChar);
}
sb.append(pe);
}
}
v = sb.toString();
}
return v;
}
示例6: testClassPathExtenderCompatibility
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public void testClassPathExtenderCompatibility () throws Exception {
final FileObject rootFolder = this.scratch.createFolder("Root");
final FileObject jarFile = TestFileUtils.writeZipFile(scratch, "archive.jar", "Test.properties:");
org.netbeans.spi.java.project.classpath.ProjectClassPathExtender extender =
prj.getLookup().lookup(org.netbeans.spi.java.project.classpath.ProjectClassPathExtender.class);
assertNotNull (extender);
extender.addArchiveFile(rootFolder);
extender.addArchiveFile(jarFile);
String cp = this.eval.getProperty("javac.classpath");
assertNotNull (cp);
String[] cpRoots = PropertyUtils.tokenizePath (cp);
assertNotNull (cpRoots);
assertEquals(2,cpRoots.length);
assertEquals(rootFolder,this.helper.resolveFileObject(cpRoots[0]));
assertEquals(jarFile,this.helper.resolveFileObject(cpRoots[1]));
}
示例7: getFreeAntName
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
@NonNull
public static String getFreeAntName (@NonNull final String name) {
if (name == null || name.length() == 0) {
throw new IllegalArgumentException ();
}
final FileObject platformsFolder = FileUtil.getConfigFile(PLATFORM_STOREGE);
String antName = PropertyUtils.getUsablePropertyName(name);
if (platformsFolder.getFileObject(antName,"xml") != null) { //NOI18N
String baseName = antName;
int index = 1;
antName = baseName + Integer.toString (index);
while (platformsFolder.getFileObject(antName,"xml") != null) { //NOI18N
index ++;
antName = baseName + Integer.toString (index);
}
}
return antName;
}
示例8: updateBuildProperties
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
private static void updateBuildProperties() {
ProjectManager.mutex().postWriteRequest(
new Runnable () {
public void run () {
try {
final EditableProperties ep = PropertyUtils.getGlobalProperties();
boolean save = updateSourceLevel(ep);
save |= updateBuildProperties (ep);
if (save) {
PropertyUtils.putGlobalProperties (ep);
}
} catch (IOException ioe) {
Exceptions.printStackTrace(ioe);
}
}
});
}
示例9: createEvaluator
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
private PropertyEvaluator createEvaluator() {
PropertyProvider predefs = helper.getStockPropertyPreprovider();
File dir = getProjectDirectoryFile();
List<PropertyProvider> providers = new ArrayList<PropertyProvider>();
providers.add(helper.getPropertyProvider("nbproject/private/platform-private.properties")); // NOI18N
providers.add(helper.getPropertyProvider("nbproject/platform.properties")); // NOI18N
PropertyEvaluator baseEval = PropertyUtils.sequentialPropertyEvaluator(predefs, providers.toArray(new PropertyProvider[providers.size()]));
providers.add(new ApisupportAntUtils.UserPropertiesFileProvider(baseEval, dir));
baseEval = PropertyUtils.sequentialPropertyEvaluator(predefs, providers.toArray(new PropertyProvider[providers.size()]));
providers.add(new DestDirProvider(baseEval));
providers.add(helper.getPropertyProvider(AntProjectHelper.PRIVATE_PROPERTIES_PATH));
providers.add(helper.getPropertyProvider(AntProjectHelper.PROJECT_PROPERTIES_PATH));
Map<String,String> fixedProps = new HashMap<String,String>();
// synchronize with suite.xml
fixedProps.put(SuiteProperties.ENABLED_CLUSTERS_PROPERTY, "");
fixedProps.put(SuiteProperties.DISABLED_CLUSTERS_PROPERTY, "");
fixedProps.put(SuiteProperties.DISABLED_MODULES_PROPERTY, "");
fixedProps.put(SuiteBrandingModel.BRANDING_DIR_PROPERTY, "branding"); // NOI18N
fixedProps.put("suite.build.dir", "build"); // NOI18N
fixedProps.put("cluster", "${suite.build.dir}/cluster"); // NOI18N
fixedProps.put("dist.dir", "dist"); // NOI18N
fixedProps.put("test.user.dir", "${suite.build.dir}/testuserdir"); // NOI18N
providers.add(PropertyUtils.fixedPropertyProvider(fixedProps));
return PropertyUtils.sequentialPropertyEvaluator(predefs, providers.toArray(new PropertyProvider[providers.size()]));
}
示例10: appendMyOwnClassPathExtensions
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
private void appendMyOwnClassPathExtensions(StringBuilder cp) {
// XXX #179578: using ModuleEntry.getClassPathExtensions would be more convenient, but the data is stale;
// should ModuleList recreate ModuleEntry's when project.xml (or project.properties, ...) changes?
Map<String,String> cpext = new ProjectXMLManager(project).getClassPathExtensions();
for (Map.Entry<String,String> entry : cpext.entrySet()) {
if (cp.length() > 0) {
cp.append(File.pathSeparatorChar);
}
String binaryOrigin = entry.getValue();
if (binaryOrigin != null) {
cp.append(project.getHelper().resolveFile(binaryOrigin));
} else {
cp.append(PropertyUtils.resolveFile(project.getModuleJarLocation().getParentFile(), entry.getKey()));
}
}
}
示例11: addFileRef
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
private void addFileRef(Map<String, String> props, String path) {
// #66275:
// XXX parts of code copied from o.n.spi.project.ant.ReferenceHelper;
// will do proper API change later with issue #70894, will also simplify impl of isssue #66188
final File normalizedFile = FileUtil.normalizeFile(PropertyUtils.resolveFile(getProjectDirectoryFile(), path));
String fileID = normalizedFile.getName();
// if the file is folder then add to ID string also parent folder name,
// i.e. if external source folder name is "src" the ID will
// be a bit more selfdescribing, e.g. project-src in case
// of ID for ant/project/src directory.
if (normalizedFile.isDirectory() && normalizedFile.getParentFile() != null) {
fileID = normalizedFile.getParentFile().getName()+"-"+normalizedFile.getName();
}
fileID = PropertyUtils.getUsablePropertyName(fileID);
// we don't need to resolve duplicate file names here, all <c-p-e>-s reside in release/modules/ext
props.put(REF_START + fileID, path);
}
示例12: browseButtonActionPerformed
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
JFileChooser chooser = new JFileChooser(ModuleUISettings.getDefault().getLastUsedClusterLocation());
chooser.setAcceptAllFileFilterUsed(false);
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int ret = chooser.showOpenDialog(this);
if (ret == JFileChooser.APPROVE_OPTION) {
File file = FileUtil.normalizeFile(chooser.getSelectedFile());
AGAIN: for (;;) {
if (! file.exists() || file.isFile() || ! ClusterUtils.isValidCluster(file)) {
if (Clusterize.clusterize(prj, file)) {
continue AGAIN;
}
} else {
ModuleUISettings.getDefault().setLastUsedClusterLocation(file.getParentFile().getAbsolutePath());
String relPath = PropertyUtils.relativizeFile(prjDir, file);
clusterDirText.setText(relPath != null ? relPath : file.getAbsolutePath());
}
break;
}
}
}
示例13: getPublicClassNames
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
public synchronized Set<String> getPublicClassNames() {
if (publicClassNames == null) {
try {
publicClassNames = computePublicClassNamesInMainModule();
String[] cpext = PropertyUtils.tokenizePath(getClassPathExtensions());
for (int i = 0; i < cpext.length; i++) {
File ext = new File(cpext[i]);
if (!ext.isFile()) {
Logger.getLogger(AbstractEntry.class.getName()).log(Level.FINE,
"Could not find Class-Path extension {0} of {1}", new Object[] {ext, this});
continue;
}
scanJarForPublicClassNames(publicClassNames, ext);
}
} catch (IOException e) {
publicClassNames = Collections.emptySet();
Util.err.annotate(e, ErrorManager.UNKNOWN, "While scanning for public classes in " + this, null, null, null); // NOI18N
Util.err.notify(ErrorManager.INFORMATIONAL, e);
}
}
return publicClassNames;
}
示例14: parseSuiteProperties
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
private static PropertyEvaluator parseSuiteProperties(File root) throws IOException {
Properties p = System.getProperties();
Map<String,String> predefs;
synchronized (p) {
predefs = NbCollections.checkedMapByCopy(p, String.class, String.class, false);
}
predefs.put("basedir", root.getAbsolutePath()); // NOI18N
PropertyProvider predefsProvider = PropertyUtils.fixedPropertyProvider(predefs);
List<PropertyProvider> providers = new ArrayList<PropertyProvider>();
providers.add(loadPropertiesFile(new File(root, "nbproject" + File.separatorChar + "private" + File.separatorChar + "platform-private.properties"))); // NOI18N
providers.add(loadPropertiesFile(new File(root, "nbproject" + File.separatorChar + "platform.properties"))); // NOI18N
PropertyEvaluator eval = PropertyUtils.sequentialPropertyEvaluator(predefsProvider, providers.toArray(new PropertyProvider[providers.size()]));
String buildS = eval.getProperty("user.properties.file"); // NOI18N
if (buildS != null) {
providers.add(loadPropertiesFile(PropertyUtils.resolveFile(root, buildS)));
} else {
// Never been opened, perhaps - so fake it.
providers.add(PropertyUtils.globalPropertyProvider());
}
providers.add(loadPropertiesFile(new File(root, "nbproject" + File.separatorChar + "private" + File.separatorChar + "private.properties"))); // NOI18N
providers.add(loadPropertiesFile(new File(root, "nbproject" + File.separatorChar + "project.properties"))); // NOI18N
eval = PropertyUtils.sequentialPropertyEvaluator(predefsProvider, providers.toArray(new PropertyProvider[providers.size()]));
providers.add(new DestDirProvider(eval));
return PropertyUtils.sequentialPropertyEvaluator(predefsProvider, providers.toArray(new PropertyProvider[providers.size()]));
}
示例15: write
import org.netbeans.spi.project.support.ant.PropertyUtils; //导入依赖的package包/类
public static void write(Project project, EclipseProjectReference ref) {
Preferences prefs = ProjectUtils.getPreferences(project, EclipseProjectReference.class, true);
File baseDir = FileUtil.toFile(project.getProjectDirectory());
if (CollocationQuery.areCollocated(baseDir, ref.eclipseProjectLocation)) {
prefs.put("project", PropertyUtils.relativizeFile(baseDir, ref.eclipseProjectLocation)); //NOI18N
} else {
prefs.put("project", ref.eclipseProjectLocation.getPath()); //NOI18N
}
if (ref.eclipseWorkspaceLocation != null) {
if (CollocationQuery.areCollocated(baseDir, ref.eclipseWorkspaceLocation)) {
prefs.put("workspace", PropertyUtils.relativizeFile(baseDir, ref.eclipseWorkspaceLocation)); //NOI18N
} else {
prefs.put("workspace", ref.eclipseWorkspaceLocation.getPath()); //NOI18N
}
}
prefs.put("timestamp", Long.toString(ref.getCurrentTimestamp())); //NOI18N
prefs.put("key", ref.key); //NOI18N
}