本文整理汇总了Java中org.mozilla.javascript.annotations.JSStaticFunction类的典型用法代码示例。如果您正苦于以下问题:Java JSStaticFunction类的具体用法?Java JSStaticFunction怎么用?Java JSStaticFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JSStaticFunction类属于org.mozilla.javascript.annotations包,在下文中一共展示了JSStaticFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseToHtml
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
@JSStaticFunction
public static void parseToHtml(final String url, final String option, final Function func) {
new Thread(new Runnable() {
@Override
public void run() {
Document document = null;
try {
document = Jsoup.connect(url).get();
Elements element = document.select(option);
func.call(context, scope, scope, new Object[] { element.html(), null });
} catch (IOException e) {
try {
func.call(context, scope, scope, new Object[] { null, e});
} catch (Exception err) {}
}
}
}).start();
}
示例2: parseToText
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
@JSStaticFunction
public static void parseToText(final String url, final String option, final Function func) throws IOException {
new Thread(new Runnable() {
@Override
public void run() {
Document document = null;
try {
document = Jsoup.connect(url).get();
Elements element = document.select(option);
func.call(context, scope, scope, new Object[] { element.text(), null });
} catch (IOException e) {
try {
func.call(context, scope, scope, new Object[] { null, e });
} catch (Exception err) {}
}
}
}).start();
}
示例3: getContext
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
@JSStaticFunction
public static Object getContext() {
Context jsContext = KakaoTalkListener.getJsEngines()[0].getContext();
ScriptableObject scope = KakaoTalkListener.getJsEngines()[0].getScope();
return jsContext.javaToJS(MainActivity.getContext(), scope);
}
示例4: addArchiveToClassPath
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
/**
* Java wrapper for {@link DistributedCache#addArchiveToClassPath(Path, Configuration)} and
* {@link DistributedCache#addArchiveToClassPath(Path, Configuration, org.apache.hadoop.fs.FileSystem)}.
*
* @param ctx the JavaScript context
* @param thisObj the 'this' object
* @param args the function arguments
* @param func the function being called
*/
@JSStaticFunction
public static void addArchiveToClassPath(final Context ctx, final Scriptable thisObj, final Object[] args,
final Function func) {
final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
final Object arg1 = args.length >= 2 ? args[1] : Undefined.instance;
if (args.length < 2) {
throw Utils.makeError(ctx, thisObj, LembosMessages.TWO_ARGS_EXPECTED);
} else if (!JavaScriptUtils.isDefined(arg0)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
} else if (!JavaScriptUtils.isDefined(arg1)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_REQUIRED);
} else if (!(arg1 instanceof ConfigurationWrap)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_MUST_BE_CONF);
}
final Configuration conf = ((ConfigurationWrap)arg1).getConf();
final Path path = new Path(URI.create(arg0.toString()));
try {
DistributedCache.addArchiveToClassPath(path, conf, path.getFileSystem(conf));
} catch (IOException e) {
throw Utils.makeError(ctx, thisObj, e.getMessage());
}
}
示例5: addCacheFile
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
/**
* Java wrapper for {@link DistributedCache#addCacheFile(URI, Configuration)}.
*
* @param ctx the JavaScript context
* @param thisObj the 'this' object
* @param args the function arguments
* @param func the function being called
*/
@JSStaticFunction
public static void addCacheFile(final Context ctx, final Scriptable thisObj, final Object[] args,
final Function func) {
final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
final Object arg1 = args.length >= 2 ? args[1] : Undefined.instance;
if (args.length < 2) {
throw Utils.makeError(ctx, thisObj, LembosMessages.TWO_ARGS_EXPECTED);
} else if (!JavaScriptUtils.isDefined(arg0)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
} else if (!JavaScriptUtils.isDefined(arg1)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_REQUIRED);
} else if (!(arg1 instanceof ConfigurationWrap)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_MUST_BE_CONF);
}
DistributedCache.addCacheFile(URI.create(arg0.toString()), ((ConfigurationWrap)arg1).getConf());
}
示例6: addLocalFiles
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
/**
* Java wrapper for {@link DistributedCache#addLocalFiles(Configuration, String)}.
*
* @param ctx the JavaScript context
* @param thisObj the 'this' object
* @param args the function arguments
* @param func the function being called
*/
@JSStaticFunction
public static void addLocalFiles(final Context ctx, final Scriptable thisObj, final Object[] args,
final Function func) {
final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
final Object arg1 = args.length >= 2 ? args[1] : Undefined.instance;
if (args.length < 2) {
throw Utils.makeError(ctx, thisObj, LembosMessages.TWO_ARGS_EXPECTED);
} else if (!JavaScriptUtils.isDefined(arg0)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
} else if (!JavaScriptUtils.isDefined(arg1)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_REQUIRED);
} else if (!(arg0 instanceof ConfigurationWrap)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_CONF);
}
DistributedCache.addLocalFiles(((ConfigurationWrap)arg0).getConf(), arg1.toString());
}
示例7: createSymlink
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
/**
* Java wrapper for {@link DistributedCache#createSymlink(Configuration)}.
*
* @param ctx the JavaScript context
* @param thisObj the 'this' object
* @param args the function arguments
* @param func the function being called
*/
@JSStaticFunction
public static void createSymlink(final Context ctx, final Scriptable thisObj, final Object[] args,
final Function func) {
final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
if (args.length < 1) {
throw Utils.makeError(ctx, thisObj, LembosMessages.ONE_ARG_EXPECTED);
} else if (!JavaScriptUtils.isDefined(arg0)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
} else if (!(arg0 instanceof ConfigurationWrap)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_CONF);
}
DistributedCache.createSymlink(((ConfigurationWrap)arg0).getConf());
}
示例8: getArchiveClassPaths
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
/**
* Java wrapper for {@link DistributedCache#getArchiveClassPaths(Configuration)}.
*
* @param ctx the JavaScript context
* @param thisObj the 'this' object
* @param args the function arguments
* @param func the function being called
*
* @return array of archive class paths
*/
@JSStaticFunction
public static Object getArchiveClassPaths(final Context ctx, final Scriptable thisObj, final Object[] args,
final Function func) {
final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
if (args.length < 1) {
throw Utils.makeError(ctx, thisObj, LembosMessages.ONE_ARG_EXPECTED);
} else if (!JavaScriptUtils.isDefined(arg0)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
} else if (!(arg0 instanceof ConfigurationWrap)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_CONF);
}
final Configuration conf = ((ConfigurationWrap)arg0).getConf();
final Path[] archiveClassPaths = DistributedCache.getArchiveClassPaths(conf);
final List<String> pathStrings = new ArrayList<>();
if (archiveClassPaths != null) {
for (final Path path : archiveClassPaths) {
pathStrings.add(path.toUri().toString());
}
}
return JavaScriptUtils.asArray(thisObj, pathStrings);
}
示例9: getFileClassPaths
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
/**
* Java wrapper for {@link DistributedCache#getFileClassPaths(Configuration)}.
*
* @param ctx the JavaScript context
* @param thisObj the 'this' object
* @param args the function arguments
* @param func the function being called
*
* @return array of file class paths
*/
@JSStaticFunction
public static Object getFileClassPaths(final Context ctx, final Scriptable thisObj, final Object[] args,
final Function func) {
final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
if (args.length < 1) {
throw Utils.makeError(ctx, thisObj, LembosMessages.ONE_ARG_EXPECTED);
} else if (!JavaScriptUtils.isDefined(arg0)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
} else if (!(arg0 instanceof ConfigurationWrap)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_CONF);
}
final Configuration conf = ((ConfigurationWrap)arg0).getConf();
final Path[] fileClassPaths = DistributedCache.getFileClassPaths(conf);
final List<String> pathStrings = new ArrayList<>();
if (fileClassPaths != null) {
for (final Path path : fileClassPaths) {
pathStrings.add(path.toUri().toString());
}
}
return JavaScriptUtils.asArray(thisObj, pathStrings);
}
示例10: getFileTimestamps
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
/**
* Java wrapper for {@link DistributedCache#getFileTimestamps(Configuration)}.
*
* @param ctx the JavaScript context
* @param thisObj the 'this' object
* @param args the function arguments
* @param func the function being called
*
* @return array of file timestamps
*/
@JSStaticFunction
public static Object getFileTimestamps(final Context ctx, final Scriptable thisObj, final Object[] args,
final Function func) {
final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
if (args.length < 1) {
throw Utils.makeError(ctx, thisObj, LembosMessages.ONE_ARG_EXPECTED);
} else if (!JavaScriptUtils.isDefined(arg0)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
} else if (!(arg0 instanceof ConfigurationWrap)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_CONF);
}
return JavaScriptUtils.asArray(thisObj, DistributedCache.getFileTimestamps(
((ConfigurationWrap)arg0).getConf()));
}
示例11: getSymlink
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
/**
* Java wrapper for {@link DistributedCache#getSymlink(Configuration)}.
*
* @param ctx the JavaScript context
* @param thisObj the 'this' object
* @param args the function arguments
* @param func the function being called
*
* @return whether or not symlinks are to be created
*/
@JSStaticFunction
public static Object getSymlink(final Context ctx, final Scriptable thisObj, final Object[] args,
final Function func) {
final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
if (args.length < 1) {
throw Utils.makeError(ctx, thisObj, LembosMessages.ONE_ARG_EXPECTED);
} else if (!JavaScriptUtils.isDefined(arg0)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
} else if (!(arg0 instanceof ConfigurationWrap)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_CONF);
}
return DistributedCache.getSymlink(((ConfigurationWrap)arg0).getConf());
}
示例12: setArchiveTimestamps
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
/**
* Java wrapper for {@link DistributedCache#setArchiveTimestamps(Configuration, String)}.
*
* @param ctx the JavaScript context
* @param thisObj the 'this' object
* @param args the function arguments
* @param func the function being called
*/
@JSStaticFunction
public static void setArchiveTimestamps(final Context ctx, final Scriptable thisObj, final Object[] args,
final Function func) {
final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
final Object arg1 = args.length >= 2 ? args[1] : Undefined.instance;
if (args.length < 2) {
throw Utils.makeError(ctx, thisObj, LembosMessages.TWO_ARGS_EXPECTED);
} else if (!JavaScriptUtils.isDefined(arg0)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
} else if (!JavaScriptUtils.isDefined(arg1)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_REQUIRED);
} else if (!(arg0 instanceof ConfigurationWrap)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_CONF);
}
DistributedCache.setArchiveTimestamps(((ConfigurationWrap)arg0).getConf(), arg1.toString());
}
示例13: setLocalArchives
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
/**
* Java wrapper for {@link DistributedCache#setLocalArchives(Configuration, String)}.
*
* @param ctx the JavaScript context
* @param thisObj the 'this' object
* @param args the function arguments
* @param func the function being called
*/
@JSStaticFunction
public static void setLocalArchives(final Context ctx, final Scriptable thisObj, final Object[] args,
final Function func) {
final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
final Object arg1 = args.length >= 2 ? args[1] : Undefined.instance;
if (args.length < 2) {
throw Utils.makeError(ctx, thisObj, LembosMessages.TWO_ARGS_EXPECTED);
} else if (!JavaScriptUtils.isDefined(arg0)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
} else if (!JavaScriptUtils.isDefined(arg1)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_REQUIRED);
} else if (!(arg0 instanceof ConfigurationWrap)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_CONF);
}
DistributedCache.setLocalArchives(((ConfigurationWrap)arg0).getConf(), arg1.toString());
}
示例14: setLocalFiles
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
/**
* Java wrapper for {@link DistributedCache#setLocalFiles(Configuration, String)}.
*
* @param ctx the JavaScript context
* @param thisObj the 'this' object
* @param args the function arguments
* @param func the function being called
*/
@JSStaticFunction
public static void setLocalFiles(final Context ctx, final Scriptable thisObj, final Object[] args,
final Function func) {
final Object arg0 = args.length >= 1 ? args[0] : Undefined.instance;
final Object arg1 = args.length >= 2 ? args[1] : Undefined.instance;
if (args.length < 2) {
throw Utils.makeError(ctx, thisObj, LembosMessages.TWO_ARGS_EXPECTED);
} else if (!JavaScriptUtils.isDefined(arg0)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_REQUIRED);
} else if (!JavaScriptUtils.isDefined(arg1)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.SECOND_ARG_REQUIRED);
} else if (!(arg0 instanceof ConfigurationWrap)) {
throw Utils.makeError(ctx, thisObj, LembosMessages.FIRST_ARG_MUST_BE_CONF);
}
DistributedCache.setLocalFiles(((ConfigurationWrap)arg0).getConf(), arg1.toString());
}
示例15: getPropertyName
import org.mozilla.javascript.annotations.JSStaticFunction; //导入依赖的package包/类
private static String getPropertyName(String methodName,
String prefix,
Annotation annotation) {
if (prefix != null) {
return methodName.substring(prefix.length());
}
String propName = null;
if (annotation instanceof JSGetter) {
propName = ((JSGetter) annotation).value();
if (propName == null || propName.length() == 0) {
if (methodName.length() > 1 && (methodName.startsWith("取") || methodName.startsWith("get"))) {
propName = methodName.substring(3);
if (Character.isUpperCase(propName.charAt(0))) {
if (propName.length() == 1) {
propName = propName.toLowerCase();
} else if (!Character.isUpperCase(propName.charAt(1))){
propName = Character.toLowerCase(propName.charAt(0))
+ propName.substring(1);
}
}
}
}
} else if (annotation instanceof JSFunction) {
propName = ((JSFunction) annotation).value();
} else if (annotation instanceof JSStaticFunction) {
propName = ((JSStaticFunction) annotation).value();
}
if (propName == null || propName.length() == 0) {
propName = methodName;
}
return propName;
}