當前位置: 首頁>>代碼示例>>Java>>正文


Java FileUtil.setMIMEType方法代碼示例

本文整理匯總了Java中org.openide.filesystems.FileUtil.setMIMEType方法的典型用法代碼示例。如果您正苦於以下問題:Java FileUtil.setMIMEType方法的具體用法?Java FileUtil.setMIMEType怎麽用?Java FileUtil.setMIMEType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.filesystems.FileUtil的用法示例。


在下文中一共展示了FileUtil.setMIMEType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();
    MockMimeLookup.setLookup(MimePath.get(MIME),
        Lookups.fixed(
            new FooEmbeddingProviderFactory(),
            new FooParserFactory()));
    FileUtil.setMIMEType(EXT, MIME);
    file1 = FileUtil.toFileObject(TestFileUtils.writeFile(
        new File(getWorkDir(),"test1.foo"),  //NOI18N
        FILE_CONTENT));
    file2 = FileUtil.toFileObject(TestFileUtils.writeFile(
        new File(getWorkDir(),"test2.foo"),  //NOI18N
        FILE_CONTENT+FILE_CONTENT));
    setBigFileSize(FILE_CONTENT.length());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:SnapshotSizeTest.java

示例2: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();
    clearWorkDir();
    MockMimeLookup.setInstances(
            MimePath.get(MIME_FOO),
            new FooParser.Factory(),
            new Task1.Factory(),
            new Task2.Factory());        
    FileUtil.setMIMEType(EXT_FOO, MIME_FOO);
    final File wd = getWorkDir();
    sourceFile = FileUtil.createData(new File(wd, "source.foo"));   //NOI18N
    assertNotNull(sourceFile);
    assertEquals(MIME_FOO, sourceFile.getMIMEType());
    source = Source.create(sourceFile);
    assertNotNull(source);
    Modification.getDefault().setSource(source);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:SchedulerEventTest.java

示例3: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
/**
 * We need our own data loader to use guarded blocks.
 */
@Override
protected void setUp() throws Exception {
    SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]); //to initialize the correct lookup instance
    FileUtil.setMIMEType("java", "text/x-java");
    MockMimeLookup.setInstances(
            MimePath.parse("text/x-java"),
            new JavaGuardedSectionsFactory(),
            new org.netbeans.modules.editor.NbEditorKit());
    MockMimeLookup mml = new MockMimeLookup();
    ClassPathProvider cpp = new ClassPathProvider() {
        public ClassPath findClassPath(FileObject file, String type) {
            if (type.equals(ClassPath.SOURCE))
                return ClassPathSupport.createClassPath(new FileObject[] {FileUtil.toFileObject(getDataDir())});
                if (type.equals(ClassPath.COMPILE))
                    return ClassPathSupport.createClassPath(new FileObject[0]);
                if (type.equals(ClassPath.BOOT))
                    return createClassPath(System.getProperty("sun.boot.class.path"));
                return null;
        }
    };
    SourceUtilsTestUtil.prepareTest(new String[0], new Object[] {mml, new GuardedDataLoader(), cpp});
    File cacheFolder = new File(getWorkDir(), "var/cache/index");
    cacheFolder.mkdirs();
    IndexUtil.setCacheFolder(cacheFolder);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:GuardedBlockTest.java

示例4: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();
    
    MockMimeLookup.setInstances(MimePath.parse("text/x-java"), new JavaKit());
    SourceUtilsTestUtil.prepareTest(new String[0], new Object[] {
        new Pool(),
        new MockMimeLookup(),
    });
    FileUtil.setMIMEType("java", "text/x-java");
    
    if (cache == null) {
        cache = getWorkDir();
        cacheFO = FileUtil.toFileObject(cache);
        
        cache.deleteOnExit();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:JavadocTestSupport.java

示例5: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    log = Log.enable("org.openide.loaders", Level.SEVERE);

    init();
    
    AddLoaderManuallyHid.addRemoveLoader(JavaDataLoader.getLoader(JavaDataLoader.class), true);
    FileUtil.setMIMEType("java", "text/x-java");
    FileUtil.setMIMEType("formKit", "application/x-form");

    root = FileUtil.createFolder(FileUtil.createMemoryFileSystem().getRoot(), "test");

    f0 = FileUtil.createData(root, "j1.java");
    f1 = FileUtil.createData(root, "f.formKit");
    f2 = FileUtil.createData(root, "f.java");
    
    assertEquals("Right mime type", "text/x-java", f2.getMIMEType());
    FormKitDataLoader.cnt = 0;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:FightWithWrongOrderInPathsTest.java

示例6: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
protected void setUp() throws Exception {
    MockLookup.init();
    clearWorkDir();
    File userdir = new File(getWorkDir(), "userdir");
    userdir.mkdirs();
    System.setProperty("netbeans.user", userdir.getAbsolutePath());
    srcFO = FileUtil.toFileObject(getWorkDir()).createFolder("src");
    srcCPImpl = new ClassPathImpl(URLMapper.findURL(srcFO, URLMapper.INTERNAL));
    srcCP = ClassPathFactory.createClassPath(srcCPImpl);
    compileCPImpl = new ClassPathImpl();
    compileCP = ClassPathFactory.createClassPath(compileCPImpl);
    bootCP = JavaPlatformManager.getDefault().getDefaultPlatform().getBootstrapLibraries();
    roots = new ArrayList<FileObject>();
    roots.add(srcFO);
    cpProvider = new ClassPathProviderImpl();
    MockLookup.setInstances(cpProvider);
    FileUtil.setMIMEType("java", "text/x-java");
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:JavaSourceTestCase.java

示例7: testMimeTypeBasedRecognition180478

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
public void testMimeTypeBasedRecognition180478() throws Exception {
    clearWorkDir();
    FileUtil.refreshAll();
    
    MockServices.setServices(JavaDataLoader.class);
    FileUtil.setMIMEType("bbb", "text/x-java");

    File wd = getWorkDir();

    new FileOutputStream(new File(wd, "Test.java")).close();
    new FileOutputStream(new File(wd, "Test.bbb")).close();

    FileUtil.refreshAll();

    FileObject f = FileUtil.toFileObject(wd);
    DataFolder df = DataFolder.findFolder(f);
    DataObject[] children = df.getChildren();

    assertEquals(2, children.length);
    assertEquals(JavaDataObject.class, children[0].getClass());
    assertEquals(JavaDataObject.class, children[1].getClass());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:JavaDataLoaderTest.java

示例8: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();
    clearWorkDir();
    MockMimeLookup.setInstances(
        MimePath.get(MIME_FOO),
        new Indexer1.Factory(),
        new Indexer2.Factory());
    final FileObject wd = FileUtil.toFileObject(getWorkDir());
    src = FileUtil.createFolder(wd,"src");                          //NOI18N
    FileUtil.createData(src, "file.foo"); //NOI18N
    Lookup.getDefault().lookup(CPProviderImpl.class).setRoot(src);
    FileUtil.setMIMEType("foo", MIME_FOO);  //NOI18N
    RepositoryUpdaterTest.setMimeTypes(MIME_FOO);
    RepositoryUpdaterTest.waitForRepositoryUpdaterInit();

    log = Logger.getLogger(RepositoryUpdater.class.getName() + ".tests"); //NOI18N
    level = log.getLevel();
    log.setLevel(Level.FINEST);
    handler = new LogHandler();
    log.addHandler(handler);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:AttachableDocumentIndexCacheTest.java

示例9: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();
    clearWorkDir();
    final FileObject wd = FileUtil.toFileObject(FileUtil.normalizeFile(getWorkDir()));
    root1 = FileUtil.createFolder(wd, "root1");
    moduleFile1 = createModule(root1, "Test");  //NOI18N
    javaFile1 = createClass(root1, "org.nb.Test");  //NOI18N
    root2 = FileUtil.createFolder(wd, "root2");
    moduleFile2 = createModule(root2, "Next");  //NOI18N
    javaFile2 = createClass(root2, "org.nb.Next");  //NOI18N
    MockServices.setServices(CPP.class, COQ.class);
    FileUtil.setMIMEType(FileObjects.JAVA, JavacParser.MIME_TYPE);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:ModuleOraculumTest.java

示例10: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    // invoke the pallete factory in advance to prevent deadlock
    HtmlPaletteFactory.getHtmlPalette();
    Utils.setUp();
    
    // to help the loader to recognize our files
    FileUtil.setMIMEType("html", "text/html");
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:EncodingTest.java

示例11: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();
    clearWorkDir();
    final File wd = getWorkDir();
    final FileObject wdo = FileUtil.toFileObject(wd);
    assertNotNull("No masterfs",wdo);   //NOI18N
    final FileObject cache = wdo.createFolder("cache"); //NOI18N
    CacheFolder.setCacheFolder(cache);
    src1 = wdo.createFolder("src1");        //NOI18N
    assertNotNull(src1);
    src2 = wdo.createFolder("src2");        //NOI18N
    assertNotNull(src2);
    src1file1 = src1.createData("test", FOO_EXT);   //NOI18N
    assertNotNull(src1file1);
    src1file2 = src1.createData("test2", FOO_EXT);  //NOI18N
    assertNotNull(src1file2);
    src2file1 = src2.createData("test", FOO_EXT);   //NOI18N
    assertNotNull(src2file1);
    src2file2 = src2.createData("test2", FOO_EXT);  //NOI18N
    assertNotNull(src2file2);

    FileUtil.setMIMEType(FOO_EXT, FOO_MIME);
    cp1 = ClassPathSupport.createClassPath(src1,src2);
    MockMimeLookup.setInstances(MimePath.get(FOO_MIME), new FooIndexerFactory());
    RepositoryUpdaterTest.setMimeTypes(FOO_MIME);
    RepositoryUpdaterTest.waitForRepositoryUpdaterInit();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:FileListWorkOrderingTest.java

示例12: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();
    this.clearWorkDir();
    final File _wd = this.getWorkDir();
    final FileObject wd = FileUtil.toFileObject(_wd);
    final FileObject cache = wd.createFolder("cache");
    CacheFolder.setCacheFolder(cache);

    assertNotNull("No masterfs",wd);        //NOI18N
    FileUtil.setMIMEType("jar", MIME_JAR);  //NOI18N
    FileUtil.setMIMEType("foo", FOO_MIME);  //NOI18N

    RepositoryUpdaterTest.waitForRepositoryUpdaterInit();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:ConstrainedBinaryIndexerTest.java

示例13: testParseWhenScanFinished

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@RandomlyFails
public void testParseWhenScanFinished () throws Exception {
    RUEmulator emulator = new RUEmulator();
    IndexingUtils.setIndexingStatus(emulator);
    emulator.setScanningInProgress(EnumSet.of(IndexingState.STARTING));

    FileUtil.setMIMEType ("foo", "text/foo");
    final FileObject workDir = FileUtil.toFileObject (getWorkDir ());
    final FileObject testFile = FileUtil.createData (workDir, "test.foo");
    final Source source = Source.create (testFile);
    final Collection<Source> sources = Collections.singleton(source);
    final TestTask tt = new TestTask();
    ParserManager.parse(sources, tt);
    assertEquals(1, tt.called);
    final Future<Void> future = ParserManager.parseWhenScanFinished(sources, tt);
    assertEquals(1, tt.called);
    assertFalse (future.isDone());
    future.cancel(false);
    assertFalse (future.isDone());
    assertTrue(future.isCancelled());

    final TestTask tt2 = new TestTask();
    final Future<Void> future2 = ParserManager.parseWhenScanFinished(sources, tt2);
    assertEquals(0, tt2.called);
    assertFalse (future2.isDone());

    final CountDownLatch countDown = new CountDownLatch(1);
    final TestTask tt3 = new TestTask(countDown);
    final Future<Void> future3 = ParserManager.parseWhenScanFinished(sources, tt3);
    assertEquals(0, tt3.called);
    assertFalse (future3.isDone());
    emulator.scan();
    assertTrue(countDown.await(10, TimeUnit.SECONDS));
    assertFalse (future.isDone());
    assertTrue (future2.isDone());
    assertTrue (future3.isDone());

    final TestTask tt4 = new TestTask();
    final Future<Void> future4 = ParserManager.parseWhenScanFinished(sources, tt4);
    assertEquals(1, tt4.called);
    assertTrue(future4.isDone());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:43,代碼來源:ParsinApiInteractionTest.java

示例14: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();

    this.clearWorkDir();
    final File _wd = this.getWorkDir();
    final FileObject wd = FileUtil.toFileObject(_wd);
    assertNotNull("No masterfs",wd);                    //NOI18N
    final FileObject cache = wd.createFolder("cache");  //NOI18N
    CacheFolder.setCacheFolder(cache);
    src1 = wd.createFolder("src1");     //NOI18N
    assertNotNull(src1);
    file1 = src1.createData("test", FOO_EXT);   //NOI18N
    assertNotNull(file1);
    FileUtil.setMIMEType(FOO_EXT, FOO_MIME);
    bin1 = wd.createFolder("bin1"); //NOI18N
    file2 = bin1.createData("test", "bin"); //NOI18N

    factory1 = new IndexerFactory("factory1", 1);   //NOI18N
    factory2 = new IndexerFactory("factory2", 1);   //NOI18N
    factory3 = new IndexerFactory("factory3", 1);   //NOI18N

    binFactory1 = new BinIndexerFactory("binFactory1", 1);  //NOI18N
    binFactory2 = new BinIndexerFactory("binFactory2", 1);  //NOI18N
    binFactory3 = new BinIndexerFactory("binFactory3", 1);  //NOI18N

    cp1 = ClassPathSupport.createClassPath(src1);
    bcp1 = ClassPathSupport.createClassPath(bin1);
    FooCPP.roots2cps = Collections.unmodifiableMap(
            new HashMap() {
                {
                    put(src1, Collections.singletonMap(FOO_SOURCES, cp1));
                    put(bin1, Collections.singletonMap(FOO_BINARY, bcp1));
                }
            });
    MockMimeLookup.setInstances(MimePath.EMPTY, binFactory1, binFactory2, binFactory3);
    MockMimeLookup.setInstances(MimePath.get(FOO_MIME), factory1, factory2, factory3);
    RepositoryUpdaterTest.setMimeTypes(FOO_MIME);

    RepositoryUpdaterTest.waitForRepositoryUpdaterInit();
    
    final Logger logger = Logger.getLogger(RepositoryUpdater.class.getName()+".tests"); //NOI18N
    logger.setLevel (Level.FINEST);
    logger.addHandler(handler);

}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:47,代碼來源:ScanStartedTest.java

示例15: setUp

import org.openide.filesystems.FileUtil; //導入方法依賴的package包/類
@Override
protected void setUp() throws Exception {
    super.setUp();
    clearWorkDir();
    final File wd = getWorkDir();
    final FileObject wdo = FileUtil.toFileObject(wd);
    assertNotNull("No masterfs",wdo);   //NOI18N
    final FileObject cache = wdo.createFolder("cache"); //NOI18N
    CacheFolder.setCacheFolder(cache);
    src1 = wdo.createFolder("src1");        //NOI18N
    assertNotNull(src1);
    src2 = wdo.createFolder("src2");        //NOI18N
    assertNotNull(src2);
    src3 = wdo.createFolder("src3");        //NOI18N
    assertNotNull(src3);
    src4 = wdo.createFolder("src4");        //NOI18N
    assertNotNull(src4);
    outside = wdo.createFolder("outside");    //NOI18N
    assertNotNull(outside);
    src1file1 = src1.createData("test", FOO_EXT);   //NOI18N
    assertNotNull(src1file1);
    src1file2 = src1.createData("test2", FOO_EXT);  //NOI18N
    assertNotNull(src1file2);
    src2fld = src2.createFolder("folder"); //NOI18N
    assertNotNull(src2fld);
    src2file1 = src2fld.createData("test", FOO_EXT);   //NOI18N
    assertNotNull(src2file1);
    src2file2 = src2fld.createData("test2", FOO_EXT);  //NOI18N
    assertNotNull(src2file2);
    src3file1 = src3.createData("test", FOO_EXT);   //NOI18N
    assertNotNull(src3file1);
    src3file2 = src3.createData("test2", FOO_EXT);  //NOI18N
    assertNotNull(src3file2);
    src4file1 = src4.createData("test", FOO_EXT);   //NOI18N
    assertNotNull(src4file1);
    src4file2 = src4.createData("test2", FOO_EXT);  //NOI18N
    assertNotNull(src4file2);

    FileUtil.setMIMEType(FOO_EXT, FOO_MIME);
    cp1 = ClassPathSupport.createClassPath(src1,src2,src3,src4);
    MockMimeLookup.setInstances(MimePath.get(FOO_MIME), new FooIndexerFactory());
    RepositoryUpdaterTest.setMimeTypes(FOO_MIME);
    RepositoryUpdaterTest.waitForRepositoryUpdaterInit();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:45,代碼來源:VisibilityChangeTest.java


注:本文中的org.openide.filesystems.FileUtil.setMIMEType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。