本文整理汇总了Java中org.openide.filesystems.FileObject.getName方法的典型用法代码示例。如果您正苦于以下问题:Java FileObject.getName方法的具体用法?Java FileObject.getName怎么用?Java FileObject.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileObject
的用法示例。
在下文中一共展示了FileObject.getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPublicTopLevelElement
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
* Finds the first public top-level type in the compilation unit given by the
* given <code>CompilationController</code>.
*
* This method assumes the restriction that there is at most a public
* top-level type declaration in a compilation unit, as described in the
* section 7.6 of the JLS.
*
* @param controller a {@link CompilationController}.
* @return the <code>TypeElement</code> encapsulating the public top-level type
* in the compilation unit given by <code>controller</code> or null
* if no such type is found.
* @throws IllegalStateException when the controller was created with no file
* objects.
*/
public static TypeElement getPublicTopLevelElement(CompilationController controller) {
Parameters.notNull("controller", controller); // NOI18N
FileObject mainFileObject = controller.getFileObject();
if (mainFileObject == null) {
throw new IllegalStateException();
}
String mainElementName = mainFileObject.getName();
List<? extends TypeElement> elements = controller.getTopLevelElements();
if (elements != null) {
for (TypeElement element : elements) {
if (element.getModifiers().contains(Modifier.PUBLIC) && element.getSimpleName().contentEquals(mainElementName)) {
return element;
}
}
}
return null;
}
示例2: searchRoot
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void searchRoot(FileObject root, String rootDisplayName) {
Enumeration ch = root.getChildren(true);
while (ch.hasMoreElements()) {
FileObject f = (FileObject) ch.nextElement();
if (f.getExt().equals(DBSchemaManager.DBSCHEMA_EXT) && !f.isFolder()) {
if (!dbschema2DisplayName.containsKey(f)) {
String relativeParent = FileUtil.getRelativePath(root, f.getParent()) + File.separator;
if (relativeParent.startsWith("/")) { // NOI18N
relativeParent = relativeParent.substring(1);
}
String relative = relativeParent + f.getName();
String displayName = NbBundle.getMessage(DBSchemaFileList.class,
"LBL_SchemaLocation", rootDisplayName, relative);
dbschema2DisplayName.put(f, displayName);
}
}
}
}
示例3: overwriteDBSchema
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
* Overwrites <code>dbschemaFile</code> with the contents of
* <code>schemaElement</code>.
*/
private static void overwriteDBSchema(SchemaElement schemaElement, FileObject dbschemaFile, DBIdentifier dbschemaName) throws IOException {
try {
schemaElement.setName(dbschemaName);
} catch (DBException e) {
IOException ioe = new IOException(e.getMessage());
ioe.initCause(e);
throw ioe;
}
// cannot just overwrite the file, DBSchemaDataObject would not
// notice the file has changed.
FileObject parent = dbschemaFile.getParent();
String fileName = dbschemaFile.getName();
String fileExt = dbschemaFile.getExt();
dbschemaFile.delete();
FileObject newDBSchemaFile = parent.createData(fileName, fileExt);
writeSchemaElement(schemaElement, newDBSchemaFile);
}
示例4: loadCategories
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static List<String> loadCategories () {
//Repository.getDefault ().findResource ("Spellcheckers");
List<String> result = new ArrayList<String> ();
FileObject root = FileUtil.getConfigFile ("Spellcheckers");
if (root != null) {
FileObject[] children = root.getChildren ();
for (FileObject fileObject : children) {
String name = null;
try {
name = fileObject.getFileSystem ().getDecorator ().annotateName (fileObject.getName (), Collections.singleton (fileObject));
} catch (FileStateInvalidException ex) {
name = fileObject.getName ();
}
Boolean b = (Boolean) fileObject.getAttribute ("Hidden");
if (b != null && b) {
result.add ("-" + name); // hidden
} else {
result.add ("+" + name);
}
}
}
Collections.sort (result, CategoryComparator);
return result;
}
示例5: isProject
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public Result isProject(@NonNull final FileObject projectDirectory) {
if (projectDirectory.getFileObject(CONVERTOR_MARKER) != null) {
try {
return new Result(
LOOKUP_FACTORY.call(),
new Callable<Project>() {
@Override
public Project call() throws Exception {
projectDirectory.createFolder(PROJECT_MARKER);
final Runnable action = CALLBACK;
if (action != null) {
action.run();
}
return ProjectManager.getDefault().findProject(projectDirectory);
}
},
projectDirectory.getName(),
null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return null;
}
示例6: addArchiveToCopy
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
* returns archive name or temporarily null cause there is no zip support
* for file protocol
*/
private static String addArchiveToCopy(CreatedModifiedFiles fileSupport, NewLibraryDescriptor.DataModel data, URL originalURL, String pathPrefix) {
String retval = null;
URL archivURL = FileUtil.getArchiveFile(originalURL);
if (archivURL != null && FileUtil.isArchiveFile(archivURL)) {
FileObject archiv = URLMapper.findFileObject(archivURL);
if (archiv == null) {
// #129617: broken library entry, just skip it.
return null;
}
retval = archiv.getNameExt();
fileSupport.add(fileSupport.createFile(pathPrefix + retval, archiv));
} else {
if ("file".equals(originalURL.getProtocol())) {//NOI18N
FileObject folderToZip;
folderToZip = URLMapper.findFileObject(originalURL);
if (folderToZip != null) {
retval = data.getLibraryName() + "-" + folderToZip.getName() + ".zip"; // NOI18N
pathPrefix += retval;
fileSupport.add(new ZipAndCopyOperation(data.getProject(),
folderToZip, pathPrefix));
}
}
}
return retval;
}
示例7: getDOPackageName
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static String getDOPackageName(FileObject f) {
ClassPath cp = ClassPath.getClassPath(f, ClassPath.SOURCE);
if (cp != null) {
return cp.getResourceName(f, '.', false);
} else {
Logger.getLogger("org.netbeans.modules.refactoring.java").info("Cannot find classpath for " + f.getPath()); //NOI18N
return f.getName();
}
}
示例8: getTags
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public java.lang.String[] getTags () {
ArrayList<String> list = new ArrayList<String> (6);
Lookup.Result<org.openide.awt.HtmlBrowser.Factory> r = Lookup.getDefault().lookupResult(org.openide.awt.HtmlBrowser.Factory.class);
for (Lookup.Item<org.openide.awt.HtmlBrowser.Factory> i: r.allItems()) {
list.add(i.getDisplayName());
}
// PENDING need to get rid of this filtering
FileObject fo = FileUtil.getConfigFile (BROWSER_FOLDER);
if (fo != null) {
DataFolder folder = DataFolder.findFolder (fo);
DataObject [] dobjs = folder.getChildren ();
for (int i = 0; i<dobjs.length; i++) {
// Must not be hidden and have to provide instances (we assume instance is HtmlBrowser.Factory)
if (Boolean.TRUE.equals(dobjs[i].getPrimaryFile().getAttribute(EA_HIDDEN)) ||
dobjs[i].getCookie(InstanceCookie.class) == null) {
FileObject fo2 = dobjs[i].getPrimaryFile();
String n = fo2.getName();
try {
n = fo2.getFileSystem().getDecorator().annotateName(n, dobjs[i].files());
} catch (FileStateInvalidException e) {
// Never mind.
}
list.remove(n);
}
}
}
String[] retValue = new String[list.size ()];
list.toArray (retValue);
return retValue;
}
示例9: getSaasFile
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public FileObject getSaasFile() throws IOException {
if (saasFile == null) {
FileObject folder = getSaasFolder();
String filename = folder.getName() + "-saas.xml"; //NOI18N
saasFile = folder.getFileObject(filename);
if (saasFile == null) {
saasFile = getSaasFolder().createData(filename);
}
}
return saasFile;
}
示例10: containsLocale
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static boolean containsLocale(PropertiesDataObject propertiesDataObject, Locale locale) {
FileObject file = propertiesDataObject.getBundleStructure().getNthEntry(0).getFile();
// FileObject file = propertiesDataObject.getPrimaryFile();
String newName = file.getName() + PropertiesDataLoader.PRB_SEPARATOR_CHAR + locale;
BundleStructure structure = propertiesDataObject.getBundleStructure();
for (int i = 0; i<structure.getEntryCount();i++) {
FileObject f = structure.getNthEntry(i).getFile();
if (newName.startsWith(f.getName()) && f.getName().length() > file.getName().length())
file = f;
}
return file.getName().equals(newName);
}
示例11: isProject2
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public ProjectManager.Result isProject2(FileObject dir) {
FileObject testproject = dir.getFileObject("testproject");
if(testproject != null && testproject.isFolder() && testproject.getFileObject("broken") != null) {
return new ProjectManager.Result(TEST_PROJECT_ICON);
}
if(testproject != null && testproject.isFolder()) {
return new ProjectManager.Result(
dir.getName(),
TEST_PROJECT_TYPE,
TEST_PROJECT_ICON);
}
return null;
}
示例12: findCompiledFile
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static FileObject findCompiledFile(FileObject sourceMapFile) {
String name = sourceMapFile.getName();
FileObject parent = sourceMapFile.getParent();
FileObject compiledFO = parent.getFileObject(name);
if (compiledFO != null) {
return compiledFO;
}
compiledFO = parent.getFileObject(name, "js");
if (compiledFO != null) {
return compiledFO;
}
return null;
}
示例13: isVisible
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public boolean isVisible(FileObject file) {
final String name = file.getName();
return !name.endsWith(INVISIBLE_SUFFIX);
}
示例14: initValues
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void initValues(FileObject template, FileObject preselectedFolder) {
if (template == null) {
throw new IllegalArgumentException(
NbBundle.getMessage(ConfigureFXMLPanelVisual.class,
"MSG_ConfigureFXMLPanel_Template_Error")); // NOI18N
}
// Show name of the project
projectTextField.setText(ProjectUtils.getInformation(project).getDisplayName());
String displayName;
try {
DataObject templateDo = DataObject.find(template);
displayName = templateDo.getNodeDelegate().getDisplayName();
} catch (DataObjectNotFoundException ex) {
displayName = template.getName();
}
putClientProperty("NewFileWizard_Title", displayName); // NOI18N
// Setup comboboxes
locationComboBox.setModel(new DefaultComboBoxModel(support.getSourceGroups().toArray()));
SourceGroupProxy preselectedGroup = SourceGroupSupport.getContainingSourceGroup(support, preselectedFolder);
ignoreRootCombo = true;
locationComboBox.setSelectedItem(preselectedGroup);
ignoreRootCombo = false;
FileObject targetFolder = preselectedFolder;
if(isMaven && support.getType().equals(JavaProjectConstants.SOURCES_TYPE_RESOURCES)) {
packageComboBox.getEditor().setItem(FXMLTemplateWizardIterator.defaultMavenFXMLPackage);
targetFolder = null;
if(preselectedGroup.isReal()) {
File f = new File(preselectedGroup.getRootFolder().getPath() + File.separator + FXMLTemplateWizardIterator.defaultMavenFXMLPackage);
if(f.exists()) {
targetFolder = FileUtil.toFileObject(f);
}
}
} else {
Object preselectedPackage = FXMLTemplateWizardIterator.getPreselectedPackage(preselectedGroup, preselectedFolder);
if (preselectedPackage != null) {
packageComboBox.getEditor().setItem(preselectedPackage);
}
}
if (template != null) {
if (fxmlNameTextField.getText().trim().length() == 0) { // To preserve the fxml name on back in the wiazard
final String baseName = template.getName();
String activeName = baseName;
if (targetFolder != null) {
int index = 0;
while (true) {
FileObject fo = targetFolder.getFileObject(activeName, JFXProjectProperties.FXML_EXTENSION);
if (fo == null) {
break;
}
activeName = baseName + ++index;
}
}
fxmlNameTextField.setText(activeName);
fxmlNameTextField.selectAll();
}
}
updatePackages();
updateText();
}
示例15: getClassName
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** get class name from specified file object*/
private static String getClassName(FileObject fo) {
// first of all try "instanceClass" property of the primary file
Object attr = fo.getAttribute ("instanceClass");
if (attr instanceof String) {
return BaseUtilities.translate((String) attr);
} else if (attr != null) {
LOG.warning(
"instanceClass was a " + attr.getClass().getName()); // NOI18N
}
attr = fo.getAttribute("instanceCreate");
if (attr != null) {
return attr.getClass().getName();
} else {
Enumeration<String> attributes = fo.getAttributes();
while (attributes.hasMoreElements()) {
if (attributes.nextElement().equals("instanceCreate")) {
// It was specified, just unloadable (usually a methodvalue).
return null;
}
}
}
// otherwise extract the name from the filename
String name = fo.getName ();
int first = name.indexOf('[') + 1;
if (first != 0) {
LOG.log(Level.WARNING, "Cannot understand {0}", fo);
}
int last = name.indexOf (']');
if (last < 0) {
last = name.length ();
}
// take only a part of the string
if (first < last) {
name = name.substring (first, last);
}
name = name.replace ('-', '.');
name = BaseUtilities.translate(name);
return name;
}