当前位置: 首页>>代码示例>>Java>>正文


Java FileObject.getExt方法代码示例

本文整理汇总了Java中org.openide.filesystems.FileObject.getExt方法的典型用法代码示例。如果您正苦于以下问题:Java FileObject.getExt方法的具体用法?Java FileObject.getExt怎么用?Java FileObject.getExt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.filesystems.FileObject的用法示例。


在下文中一共展示了FileObject.getExt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
        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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:DBSchemaManager.java

示例2: getReader

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private Reader getReader(FileObject fo, String encoding, FileObject type, String secondFileExt) throws FileNotFoundException {
    if (encoding != null) {
        try {
            return new InputStreamReader(fo.getInputStream(), encoding);
        } catch (UnsupportedEncodingException ueex) {
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ueex);
        }
    }
    Reader r = null;
    String ext = type.getExt();
    if (!"java".equalsIgnoreCase(ext) || !ext.equals(secondFileExt)) {// We read the encoding for Java files explicitely
                                        // If it's not defined, read with default encoding from stream (because of guarded blocks)
                                        // But when the extensions of the two files are different (comparing Java files with something else),
                                        // we have to use the Document approach for both due to possible different line-endings.
        r = getReaderFromEditorSupport(fo, type);
        if (r == null) {
            r = getReaderFromKit(null, fo, type.getMIMEType());
        }
    }
    if (r == null) {
        // Fallback, use current encoding
        r = new InputStreamReader(fo.getInputStream());
    }
    return r;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:EncodedReaderFactory.java

示例3: createContextAwareInstance

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public Action createContextAwareInstance(Lookup lookup) {
    String textlintPath = TextlintOptions.getInstance().getTextlintPath();
    if (textlintPath == null || textlintPath.isEmpty()) {
        OptionsDisplayer.getDefault().open(TextlintOptionsPanelController.OPTIONS_FULL_PATH);
        return this;
    }
    DataObject dataObject = lookup.lookup(DataObject.class);
    if (dataObject == null) {
        return this;
    }
    FileObject fileObject = dataObject.getPrimaryFile();
    if (fileObject == null) {
        return this;
    }
    String ext = fileObject.getExt();
    if ("md".equals(ext) || "txt".endsWith(ext) // NOI18N
            || ("html".equals(ext) && TextlintOptions.getInstance().isHtmlEnabled())) { // NOI18N
        return new RefreshAction(dataObject);
    }
    return this;
}
 
开发者ID:junichi11,项目名称:netbeans-textlint-plugin,代码行数:23,代码来源:RefreshAction.java

示例4: compareExtensions

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** for sorting folders first and then by extensions and then by names */
private int compareExtensions(Object o1, Object o2) {
    FileObject obj1 = findFileObject(o1);
    FileObject obj2 = findFileObject(o2);

    boolean folder1 = obj1.isFolder();
    boolean folder2 = obj2.isFolder();

    if (folder1 != folder2) {
        return folder1 ? -1 : 1; // folders first
    } else if (folder1) { // && folder2
        return obj1.getNameExt().compareTo(obj2.getNameExt()); // by nameExt
    } else {
        String ext1 = obj1.getExt();
        String ext2 = obj2.getExt();
        if (ext1.equals(ext2)) { // same extensions
            return obj1.getName().compareTo(obj2.getName()); // by name
        } else { // different extensions
            return ext1.compareTo(ext2); // by extension
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:FolderComparator.java

示例5: findPrimaryFile

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
protected FileObject findPrimaryFile(FileObject fo)
{
    LOG.info("FormKitDataLoader.findPrimaryFile(): " + fo.getNameExt());
    cnt++;

    String ext = fo.getExt();
    if (ext.equals(FORM_EXTENSION))
    {
        return FileUtil.findBrother(fo, JAVA_EXTENSION);
    }
    if (ext.equals(JAVA_EXTENSION) && FileUtil.findBrother(fo, FORM_EXTENSION) != null)
    {
        return fo;
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:FightWithWrongOrderOfLoadersTest.java

示例6: findPrimaryFile

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
protected FileObject findPrimaryFile(FileObject fo) {

    if (fo.isFolder()) {
        return null;
    }

    // check if it's itself the primary file
    String ext = fo.getExt();
    if (ext.equalsIgnoreCase(PRIMARY_EXTENSION)) {
        return fo;
    }

    // check if it's a secondary entry
    String completeFileName = fo.getNameExt();
    Matcher m = SECONDARY_PATTERN.matcher(completeFileName);
    if (m.find()) {
        String primaryName = m.group(1);
        FileObject primaryFO = fo.getParent().getFileObject(primaryName, PRIMARY_EXTENSION);
        return primaryFO;
    }

    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:FileObjectInLookupByMatteoTest.java

示例7: findPrimaryFile

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
protected FileObject findPrimaryFile(FileObject fo)
{
    LOG.info("FXKitDataLoader.findPrimaryFile(): " + fo.getNameExt());
    cnt++;

    String ext = fo.getExt();
    if (ext.equals(FX_EXT))
    {
        return FileUtil.findBrother(fo, JAVA_EXTENSION);
    }
    if (ext.equals(JAVA_EXTENSION) && FileUtil.findBrother(fo, FX_EXT) != null)
    {
        return fo;
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:MultiDataObjectDeleteSecondaryEntryTest.java

示例8: findPrimaryFile

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** For a given file finds a primary file.
    * @param fo the file to find primary file for
    *
    * @return the primary file for the file or null if the file is not
    *   recognized by this loader
    */
   @Override
   protected FileObject findPrimaryFile(FileObject fo) {
// never recognize folders.
       if (fo.isFolder()) return null;
       String ext = fo.getExt();
       if (ext.equals(FORM_EXTENSION))
           return FileUtil.findBrother(fo, JAVA_EXTENSION);

       FileObject javaFile = findJavaPrimaryFile(fo);
       return javaFile != null
                   && FileUtil.findBrother(javaFile, FORM_EXTENSION) != null ?
           javaFile : null;
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:FormDataLoader.java

示例9: testComposeNameImpl

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void testComposeNameImpl(FileObject fo) throws IOException {
    assertTrue(fo.isValid() && fo.isData());
    String fullName = fo.getNameExt();
    String ext = fo.getExt();
    String name = fo.getName();
    FileObject parent = fo.getParent();
    fo.delete();
    FileObject fo2 = parent.createData(name, ext);
    assertEquals(fullName, fo2.getNameExt());
    assertEquals(name, fo2.getName());
    assertEquals(ext, fo2.getExt());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:BaseFileObjectTestHid.java

示例10: createNoSourceNode

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static Node createNoSourceNode(FileObject bi) {
    String name = bi.getName();
    name = name.substring(0, name.length() - "BeanInfo".length()); // NOI18N
    String ext = bi.getExt();
    if (ext.length() > 0) {
        name += '.' + ext;
    }
    String msg = NbBundle.getMessage(BiNode.class, "CTL_NODE_MissingBeanFile", name);
    return new Error(msg);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:BiNode.java

示例11: testSameWithGC

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** Test whether instances survive garbage collection.
 */
public void testSameWithGC () throws Exception {
    FileObject tsFO = root.createFolder("testSameWithGC");
    assertNotNull("folder 'testSameWithGC' is not created!", tsFO);
    DataFolder folder = (DataFolder) DataObject.find(tsFO).getCookie(DataFolder.class);
    assertNotNull("missing data folder" + folder);
    
    FooSetting ser = new FooSetting("testSameWithGC");
    
    FileObject prim = InstanceDataObject.create (folder, "MyName", ser, null).getPrimaryFile ();
    String name = prim.getName ();
    String ext = prim.getExt ();
    prim = null;

    System.gc ();
    System.gc ();
    System.gc ();
    System.gc ();
    System.gc ();
    System.gc ();
    System.gc ();
    System.gc ();
    System.gc ();
    
    FileObject fo = folder.getPrimaryFile ().getFileObject (name, ext);
    assertNotNull ("MyName.settings not found", fo);
    
    DataObject obj = DataObject.find (fo);
    
    InstanceCookie.Of ic = (InstanceCookie.Of) obj.getCookie(InstanceCookie.Of.class);
    assertNotNull (obj + " does not contain instance cookie", ic);
    
    assertTrue("instanceOf failed", ic.instanceOf(ser.getClass()));
    assertEquals("instanceClass", ser.getClass(), ic.instanceClass());
    
    Object value = ic.instanceCreate ();
    assertEquals("Value is different from stored one", System.identityHashCode(ser), System.identityHashCode(value));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:XMLPropertiesConvertorTest.java

示例12: testSaveAsOverwriteExisting

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testSaveAsOverwriteExisting() throws IOException {
    FileObject fo = obj2.getPrimaryFile();
    String newName = fo.getName();
    String newExt = fo.getExt();
    DataFolder folder = DataFolder.findFolder( fo.getParent() );
    
    try {
        obj1.copyRename( folder, newName, newExt );
        fail( "default implementation of copyRename cannot overwrite existing files" );
    } catch( IOException e ) {
        //this is what we want
    }
    
    sfs.assertEvent(obj1, 0, null);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:DataObjectSaveAsTest.java

示例13: pathMatches

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public boolean pathMatches(FileObject fileObject) {
    String fileExt = fileObject.getExt();
    return fileExt != null && fileExt.equalsIgnoreCase(ext);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:FileNameMatcher.java

示例14: createFromTemplate

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public List<FileObject> createFromTemplate(CreateDescriptor desc) throws IOException {
    FileObject template = desc.getTemplate();
    String name = desc.getProposedName();
    Map<String, ?> values = desc.getParameters();
    FileObject f = desc.getTarget();
    
    boolean noExt = desc.hasFreeExtension() && name.indexOf('.') != -1;
    
    String extWithDot;
    if (noExt) {
        extWithDot = null;
    } else {
        extWithDot = '.' + template.getExt();
        if (name.endsWith(extWithDot)) { // Test whether the extension happens to be there already
            // And remove it if yes, it will be appended to the unique name.
            name = name.substring(0, name.length() - extWithDot.length());
        }
    }
    
    String nameUniq = FileUtil.findFreeFileName(f, name, noExt ? null : template.getExt());
    FileObject output = FileUtil.createData(f, noExt ? nameUniq : nameUniq + extWithDot);
    Charset targetEnc = FileEncodingQuery.getEncoding(output);
    Charset sourceEnc = FileEncodingQuery.getEncoding(template);
    
    ScriptEngine eng = engine(template);
    Bindings bind = eng.getContext().getBindings(ScriptContext.ENGINE_SCOPE);
    bind.putAll(values);
    
    if(!values.containsKey(ENCODING_PROPERTY_NAME)) {
        bind.put(ENCODING_PROPERTY_NAME, targetEnc.name());
    }
    
    //Document doc = createDocument(template.getMIMEType());
    FileLock lock = output.lock();
    try (Writer w = new OutputStreamWriter(output.getOutputStream(lock), targetEnc);
         Reader is = new InputStreamReader(template.getInputStream(), sourceEnc);
        /*IndentWriter w2 = new IndentWriter(doc, 0, w, false) */) {
        StringWriter sw = new StringWriter();
        ScriptEngine eng2 = desc.isPreformatted() ? null : indentEngine();
        
        eng.getContext().setWriter(new PrintWriter(eng2 != null ? sw : w));
        //eng.getContext().setBindings(bind, ScriptContext.ENGINE_SCOPE);
        eng.getContext().setAttribute(FileObject.class.getName(), template, ScriptContext.ENGINE_SCOPE);
        eng.getContext().setAttribute(ScriptEngine.FILENAME, template.getNameExt(), ScriptContext.ENGINE_SCOPE);
        eng.eval(is);
        
        if (eng2 != null) {
            eng2.getContext().setAttribute("mimeType", template.getMIMEType(), ScriptContext.ENGINE_SCOPE);
            eng2.getContext().setWriter(w);
            eng2.eval(new StringReader(sw.toString()));
        }
    }catch (ScriptException ex) {
        IOException io = new IOException(ex.getMessage(), ex);
        throw io;
    } finally {
        lock.releaseLock();
    }
    return Collections.singletonList(output);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:61,代码来源:ScriptingCreateFromTemplateHandler.java

示例15: hasVirtualSource

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static boolean hasVirtualSource (final FileObject file) {
    Parameters.notNull("file", file);
    final String ext = file.getExt();
    return getExt2ProvMap().keySet().contains(ext);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:VirtualSourceProviderQuery.java


注:本文中的org.openide.filesystems.FileObject.getExt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。