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


Java ScriptEngineFactory.getMimeTypes方法代碼示例

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


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

示例1: list

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
@Test
public void list() {
	ScriptEngineManager manager = new ScriptEngineManager();
	List<ScriptEngineFactory> factories = manager.getEngineFactories();
	for (ScriptEngineFactory factory : factories) {
		System.out.println(String.format("Engine: %s v%s; %s v%s",
				factory.getEngineName(),
				factory.getEngineVersion(),
				factory.getLanguageName(),
				factory.getLanguageVersion()));
		List<String> extensions = factory.getExtensions();
		System.out.println("Extensions:");
		print(extensions);

		List<String> names = factory.getNames();
		System.out.println("Names:");
		print(names);

		List<String> mimeTypes = factory.getMimeTypes();
		System.out.println("MIME Types:");
		print(mimeTypes);
	}
}
 
開發者ID:RockManJoe64,項目名稱:fixprotocol-test-suite,代碼行數:24,代碼來源:ListAllEngines.java

示例2: getEditorMimetypeForScriptEngineFactory

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
private String getEditorMimetypeForScriptEngineFactory(ScriptEngineFactory factory) {
	String retVal = null;
	
	// look for the first listed mimetype starting with 'text/'
	for(String mimetype:factory.getMimeTypes()) {
		if(mimetype.startsWith("text/")) {
			retVal = mimetype;
			break;
		}
	}
	// didn't find one - use 'text/<lang>'
	if(retVal == null) {
		retVal = "text/" + factory.getLanguageName().toLowerCase();
	}
	
	return retVal;
}
 
開發者ID:phon-ca,項目名稱:phon,代碼行數:18,代碼來源:ResultListingSectionPanel.java

示例3: loadModules

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
@Override
public void loadModules() {

    super.loadModules();

    List<ScriptEngineFactory> factories = getModules();

    for (ScriptEngineFactory factory : factories) {
        _engineManager.registerEngineName(factory.getEngineName(), factory);

        List<String> extensions = factory.getExtensions();
        for (String ext : extensions) {
            _engineManager.registerEngineExtension(ext, factory);
        }

        List<String> mimes = factory.getMimeTypes();
        for (String mime : mimes) {
            _engineManager.registerEngineExtension(mime, factory);
        }

        NucMsg.info("Loaded script engine: {0}", factory.getEngineName());
    }
}
 
開發者ID:JCThePants,項目名稱:NucleusFramework,代碼行數:24,代碼來源:InternalScriptEngineLoader.java

示例4: sameMimeTypes

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
private static boolean sameMimeTypes(final ScriptEngineFactory factory, final String engine) {
    final List<String> mimeTypes = factory.getMimeTypes();
    if (mimeTypes != null) {
        for (final String mimeType : mimeTypes) {
            if (TextUtils.containsIgnoreCase(mimeType, engine)) {
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:vbauer,項目名稱:jconditions,代碼行數:12,代碼來源:ScriptUtils.java

示例5: showEngineDetails

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
private void showEngineDetails(JComponent parent, ScriptEngineFactory scriptEngineFactory) {
    StringBuilder out = new StringBuilder();

    out.append(String.format("Engine name: %s\n", scriptEngineFactory.getEngineName()));
    out.append(String.format("Engine version: %s\n", scriptEngineFactory.getEngineVersion()));
    out.append(String.format("Language name: %s\n", scriptEngineFactory.getLanguageName()));
    out.append(String.format("Language version: %s\n", scriptEngineFactory.getLanguageVersion()));

    out.append("File name extension(s):");
    final List<String> extensions = scriptEngineFactory.getExtensions();
    for (String extension : extensions) {
        out.append(" ");
        out.append(extension);
    }
    out.append("\n");

    out.append("File content type(s):");
    final List<String> mimeTypes = scriptEngineFactory.getMimeTypes();
    for (String mimeType : mimeTypes) {
        out.append(" ");
        out.append(mimeType);
    }
    out.append("\n");

    out.append("Engine factory name(s): ");
    final List<String> names = scriptEngineFactory.getNames();
    for (String name : names) {
        out.append(" ");
        out.append(name);
    }
    out.append("\n");

    JOptionPane.showMessageDialog(parent, out.toString(), "Script Engine Details", JOptionPane.INFORMATION_MESSAGE);
}
 
開發者ID:senbox-org,項目名稱:snap-desktop,代碼行數:35,代碼來源:NewAction.java

示例6: factoryTests

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
@Test
public void factoryTests() {
    final ScriptEngineManager m = new ScriptEngineManager();
    final ScriptEngine e = m.getEngineByName("nashorn");
    assertNotNull(e);

    final ScriptEngineFactory fac = e.getFactory();

    assertEquals(fac.getLanguageName(), "ECMAScript");
    assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript");
    assertEquals(fac.getLanguageVersion(), "ECMA - 262 Edition 5.1");
    assertEquals(fac.getEngineName(), "Oracle Nashorn");
    assertEquals(fac.getOutputStatement("context"), "print(context)");
    assertEquals(fac.getProgram("print('hello')", "print('world')"), "print('hello');print('world');");
    assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript");

    boolean seenJS = false;
    for (final String ext : fac.getExtensions()) {
        if (ext.equals("js")) {
            seenJS = true;
        }
    }

    assertEquals(seenJS, true);
    final String str = fac.getMethodCallSyntax("obj", "foo", "x");
    assertEquals(str, "obj.foo(x)");

    boolean seenNashorn = false, seenJavaScript = false, seenECMAScript = false;
    for (final String name : fac.getNames()) {
        switch (name) {
            case "nashorn": seenNashorn = true; break;
            case "javascript": seenJavaScript = true; break;
            case "ECMAScript": seenECMAScript = true; break;
        default:
            break;
        }
    }

    assertTrue(seenNashorn);
    assertTrue(seenJavaScript);
    assertTrue(seenECMAScript);

    boolean seenAppJS = false, seenAppECMA = false, seenTextJS = false, seenTextECMA = false;
    for (final String mime : fac.getMimeTypes()) {
        switch (mime) {
            case "application/javascript": seenAppJS = true; break;
            case "application/ecmascript": seenAppECMA = true; break;
            case "text/javascript": seenTextJS = true; break;
            case "text/ecmascript": seenTextECMA = true; break;
        default:
            break;
        }
    }

    assertTrue(seenAppJS);
    assertTrue(seenAppECMA);
    assertTrue(seenTextJS);
    assertTrue(seenTextECMA);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:60,代碼來源:ScriptEngineTest.java

示例7: testScriptEngineFactory

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
/**
 * Tests the Lua script engine factory.
 */
@Test
public void testScriptEngineFactory() {
	// Get factory
	ScriptEngineFactory factory = scriptEngine.getFactory();

	// getEngineName()
	assertEquals("JNLua", factory.getEngineName());

	// getEngineVersion()
	assertEquals("1.0", factory.getEngineVersion());

	// getNames()
	List<String> names = factory.getNames();
	assertTrue(names.contains("lua"));
	assertTrue(names.contains("Lua"));
	assertTrue(names.contains("jnlua"));
	assertTrue(names.contains("JNLua"));

	// getLanguageName()
	assertEquals("Lua", factory.getLanguageName());

	// getLanguageVersion()
	assertEquals("5.2", factory.getLanguageVersion());

	// getExtensions()
	List<String> extensions = factory.getExtensions();
	assertTrue(extensions.contains("lua"));

	// getMimeTypes()
	List<String> mimeTypes = factory.getMimeTypes();
	assertTrue(mimeTypes.contains("application/x-lua"));
	assertTrue(mimeTypes.contains("text/x-lua"));

	// getParameter()
	assertEquals(factory.getEngineName(), factory
			.getParameter(ScriptEngine.ENGINE));
	assertEquals(factory.getEngineVersion(), factory
			.getParameter(ScriptEngine.ENGINE_VERSION));
	assertTrue(factory.getNames().contains(
			factory.getParameter(ScriptEngine.NAME)));
	assertEquals(factory.getLanguageName(), factory
			.getParameter(ScriptEngine.LANGUAGE));
	assertEquals(factory.getLanguageVersion(), factory
			.getParameter(ScriptEngine.LANGUAGE_VERSION));

	// getScriptEngine()
	assertNotNull(factory.getScriptEngine());

	// getMethodCallSyntax()
	assertEquals("process:execute(a, b)", factory.getMethodCallSyntax(
			"process", "execute", "a", "b"));

	// getOutputStatement()
	assertEquals("print(\"test\")", factory.getOutputStatement("test"));
	assertEquals("print(\"\\\"quoted\\\"\")", factory
			.getOutputStatement("\"quoted\""));

	// getProgram()
	assertEquals("a = 1\nreturn b\n", factory.getProgram("a = 1",
			"return b"));
}
 
開發者ID:airminer,項目名稱:jnlua,代碼行數:65,代碼來源:LuaScriptEngineTest.java

示例8: factoryTests

import javax.script.ScriptEngineFactory; //導入方法依賴的package包/類
@Test
public void factoryTests() {
    final ScriptEngineManager m = new ScriptEngineManager();
    final ScriptEngine e = m.getEngineByName("nashorn");
    assertNotNull(e);

    final ScriptEngineFactory fac = e.getFactory();

    assertEquals(fac.getLanguageName(), "ECMAScript");
    assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript");
    assertEquals(fac.getLanguageVersion(), "ECMA - 262 Edition 5.1");
    assertEquals(fac.getEngineName(), "Oracle Nashorn");
    assertEquals(fac.getOutputStatement("context"), "print(context)");
    assertEquals(fac.getProgram("print('hello')", "print('world')"), "print('hello');print('world');");
    assertEquals(fac.getParameter(ScriptEngine.NAME), "javascript");

    boolean seenJS = false;
    for (String ext : fac.getExtensions()) {
        if (ext.equals("js")) {
            seenJS = true;
        }
    }

    assertEquals(seenJS, true);
    String str = fac.getMethodCallSyntax("obj", "foo", "x");
    assertEquals(str, "obj.foo(x)");

    boolean seenNashorn = false, seenJavaScript = false, seenECMAScript = false;
    for (String name : fac.getNames()) {
        switch (name) {
            case "nashorn": seenNashorn = true; break;
            case "javascript": seenJavaScript = true; break;
            case "ECMAScript": seenECMAScript = true; break;
        }
    }

    assertTrue(seenNashorn);
    assertTrue(seenJavaScript);
    assertTrue(seenECMAScript);

    boolean seenAppJS = false, seenAppECMA = false, seenTextJS = false, seenTextECMA = false;
    for (String mime : fac.getMimeTypes()) {
        switch (mime) {
            case "application/javascript": seenAppJS = true; break;
            case "application/ecmascript": seenAppECMA = true; break;
            case "text/javascript": seenTextJS = true; break;
            case "text/ecmascript": seenTextECMA = true; break;
        }
    }

    assertTrue(seenAppJS);
    assertTrue(seenAppECMA);
    assertTrue(seenTextJS);
    assertTrue(seenTextECMA);
}
 
開發者ID:RedlineResearch,項目名稱:OLD-OpenJDK8,代碼行數:56,代碼來源:ScriptEngineTest.java


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