repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java | ClassScanner.setClassLoaderProvider | public void setClassLoaderProvider(String id, ClassLoaderProvider classLoaderProvider) {
if (classLoaderProvider != null) {
classLoaderProviderMap.put(id, classLoaderProvider);
} else {
classLoaderProviderMap.remove(id);
}
} | java | public void setClassLoaderProvider(String id, ClassLoaderProvider classLoaderProvider) {
if (classLoaderProvider != null) {
classLoaderProviderMap.put(id, classLoaderProvider);
} else {
classLoaderProviderMap.remove(id);
}
} | [
"public",
"void",
"setClassLoaderProvider",
"(",
"String",
"id",
",",
"ClassLoaderProvider",
"classLoaderProvider",
")",
"{",
"if",
"(",
"classLoaderProvider",
"!=",
"null",
")",
"{",
"classLoaderProviderMap",
".",
"put",
"(",
"id",
",",
"classLoaderProvider",
")",
... | Registers a named class loader provider or removes it if the classLoaderProvider is null | [
"Registers",
"a",
"named",
"class",
"loader",
"provider",
"or",
"removes",
"it",
"if",
"the",
"classLoaderProvider",
"is",
"null"
] | d8b1c8f246307c0313ba297a494106d0859f3ffd | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java#L82-L88 | train |
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java | ClassScanner.findClassNames | public SortedSet<String> findClassNames(String search, Integer limit) {
Map<Package, ClassLoader[]> packageMap = Packages.getPackageMap(getClassLoaders(), ignorePackages);
return findClassNamesInPackages(search, limit, packageMap);
} | java | public SortedSet<String> findClassNames(String search, Integer limit) {
Map<Package, ClassLoader[]> packageMap = Packages.getPackageMap(getClassLoaders(), ignorePackages);
return findClassNamesInPackages(search, limit, packageMap);
} | [
"public",
"SortedSet",
"<",
"String",
">",
"findClassNames",
"(",
"String",
"search",
",",
"Integer",
"limit",
")",
"{",
"Map",
"<",
"Package",
",",
"ClassLoader",
"[",
"]",
">",
"packageMap",
"=",
"Packages",
".",
"getPackageMap",
"(",
"getClassLoaders",
"(... | Searches for the available class names given the text search
@return all the class names found on the current classpath using the given text search filter | [
"Searches",
"for",
"the",
"available",
"class",
"names",
"given",
"the",
"text",
"search"
] | d8b1c8f246307c0313ba297a494106d0859f3ffd | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java#L95-L98 | train |
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java | ClassScanner.getAllClassesMap | public SortedMap<String, Class<?>> getAllClassesMap() {
Package[] packages = Package.getPackages();
return getClassesMap(packages);
} | java | public SortedMap<String, Class<?>> getAllClassesMap() {
Package[] packages = Package.getPackages();
return getClassesMap(packages);
} | [
"public",
"SortedMap",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"getAllClassesMap",
"(",
")",
"{",
"Package",
"[",
"]",
"packages",
"=",
"Package",
".",
"getPackages",
"(",
")",
";",
"return",
"getClassesMap",
"(",
"packages",
")",
";",
"}"
] | Returns all the classes found in a sorted map | [
"Returns",
"all",
"the",
"classes",
"found",
"in",
"a",
"sorted",
"map"
] | d8b1c8f246307c0313ba297a494106d0859f3ffd | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java#L220-L223 | train |
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java | ClassScanner.getClassesMap | public SortedMap<String, Class<?>> getClassesMap(Package... packages) {
SortedMap<String, Class<?>> answer = new TreeMap<String, Class<?>>();
Map<String, ClassResource> urlSet = new HashMap<String, ClassResource>();
for (Package aPackage : packages) {
addPackageResources(aPackage, urlSet, classLoaders);
}
for (ClassResource classResource : urlSet.values()) {
Set<Class<?>> classes = getClassesForPackage(classResource, null, null);
for (Class<?> aClass : classes) {
answer.put(aClass.getName(), aClass);
}
}
return answer;
} | java | public SortedMap<String, Class<?>> getClassesMap(Package... packages) {
SortedMap<String, Class<?>> answer = new TreeMap<String, Class<?>>();
Map<String, ClassResource> urlSet = new HashMap<String, ClassResource>();
for (Package aPackage : packages) {
addPackageResources(aPackage, urlSet, classLoaders);
}
for (ClassResource classResource : urlSet.values()) {
Set<Class<?>> classes = getClassesForPackage(classResource, null, null);
for (Class<?> aClass : classes) {
answer.put(aClass.getName(), aClass);
}
}
return answer;
} | [
"public",
"SortedMap",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"getClassesMap",
"(",
"Package",
"...",
"packages",
")",
"{",
"SortedMap",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"answer",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"... | Returns all the classes found in a sorted map for the given list of packages | [
"Returns",
"all",
"the",
"classes",
"found",
"in",
"a",
"sorted",
"map",
"for",
"the",
"given",
"list",
"of",
"packages"
] | d8b1c8f246307c0313ba297a494106d0859f3ffd | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java#L228-L241 | train |
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java | ClassScanner.findClass | public Class<?> findClass(String className) throws ClassNotFoundException {
for (String skip : SKIP_CLASSES) {
if (skip.equals(className)) {
return null;
}
}
for (ClassLoader classLoader : getClassLoaders()) {
try {
return classLoader.loadClass(className);
} catch (ClassNotFoundException e) {
// ignore
}
}
return Class.forName(className);
} | java | public Class<?> findClass(String className) throws ClassNotFoundException {
for (String skip : SKIP_CLASSES) {
if (skip.equals(className)) {
return null;
}
}
for (ClassLoader classLoader : getClassLoaders()) {
try {
return classLoader.loadClass(className);
} catch (ClassNotFoundException e) {
// ignore
}
}
return Class.forName(className);
} | [
"public",
"Class",
"<",
"?",
">",
"findClass",
"(",
"String",
"className",
")",
"throws",
"ClassNotFoundException",
"{",
"for",
"(",
"String",
"skip",
":",
"SKIP_CLASSES",
")",
"{",
"if",
"(",
"skip",
".",
"equals",
"(",
"className",
")",
")",
"{",
"retu... | Finds a class from its name | [
"Finds",
"a",
"class",
"from",
"its",
"name"
] | d8b1c8f246307c0313ba297a494106d0859f3ffd | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java#L252-L267 | train |
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java | ClassScanner.optionallyFindClasses | public List<Class<?>> optionallyFindClasses(Iterable<String> classNames) {
List<Class<?>> answer = new ArrayList<Class<?>>();
for (String className : classNames) {
Class<?> aClass = optionallyFindClass(className);
if (aClass != null) {
answer.add(aClass);
}
}
return answer;
} | java | public List<Class<?>> optionallyFindClasses(Iterable<String> classNames) {
List<Class<?>> answer = new ArrayList<Class<?>>();
for (String className : classNames) {
Class<?> aClass = optionallyFindClass(className);
if (aClass != null) {
answer.add(aClass);
}
}
return answer;
} | [
"public",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"optionallyFindClasses",
"(",
"Iterable",
"<",
"String",
">",
"classNames",
")",
"{",
"List",
"<",
"Class",
"<",
"?",
">",
">",
"answer",
"=",
"new",
"ArrayList",
"<",
"Class",
"<",
"?",
">",
">",
... | Tries to find as many of the class names on the class loaders as possible and return them | [
"Tries",
"to",
"find",
"as",
"many",
"of",
"the",
"class",
"names",
"on",
"the",
"class",
"loaders",
"as",
"possible",
"and",
"return",
"them"
] | d8b1c8f246307c0313ba297a494106d0859f3ffd | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java#L284-L293 | train |
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java | ClassScanner.withinLimit | protected boolean withinLimit(Integer limit, Collection<?> collection) {
if (limit == null) {
return true;
} else {
int value = limit.intValue();
return value <= 0 || value > collection.size();
}
} | java | protected boolean withinLimit(Integer limit, Collection<?> collection) {
if (limit == null) {
return true;
} else {
int value = limit.intValue();
return value <= 0 || value > collection.size();
}
} | [
"protected",
"boolean",
"withinLimit",
"(",
"Integer",
"limit",
",",
"Collection",
"<",
"?",
">",
"collection",
")",
"{",
"if",
"(",
"limit",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"int",
"value",
"=",
"limit",
".",
"intValue"... | Returns true if we are within the limit value for the number of results in the collection | [
"Returns",
"true",
"if",
"we",
"are",
"within",
"the",
"limit",
"value",
"for",
"the",
"number",
"of",
"results",
"in",
"the",
"collection"
] | d8b1c8f246307c0313ba297a494106d0859f3ffd | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/introspect/support/ClassScanner.java#L537-L544 | train |
hawtio/hawtio | hawtio-log/src/main/java/io/hawt/log/log4j/MavenCoordHelper.java | MavenCoordHelper.findClass | protected static Class findClass(final String className) throws ClassNotFoundException {
try {
return Thread.currentThread().getContextClassLoader().loadClass(className);
} catch (ClassNotFoundException e) {
try {
return Class.forName(className);
} catch (ClassNotFoundException e1) {
return MavenCoordHelper.class.getClassLoader().loadClass(className);
}
}
} | java | protected static Class findClass(final String className) throws ClassNotFoundException {
try {
return Thread.currentThread().getContextClassLoader().loadClass(className);
} catch (ClassNotFoundException e) {
try {
return Class.forName(className);
} catch (ClassNotFoundException e1) {
return MavenCoordHelper.class.getClassLoader().loadClass(className);
}
}
} | [
"protected",
"static",
"Class",
"findClass",
"(",
"final",
"String",
"className",
")",
"throws",
"ClassNotFoundException",
"{",
"try",
"{",
"return",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
".",
"loadClass",
"(",
"classN... | Find class given class name.
@param className class name, may not be null.
@return class, will not be null.
@throws ClassNotFoundException thrown if class can not be found. | [
"Find",
"class",
"given",
"class",
"name",
"."
] | d8b1c8f246307c0313ba297a494106d0859f3ffd | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-log/src/main/java/io/hawt/log/log4j/MavenCoordHelper.java#L105-L115 | train |
hawtio/hawtio | hawtio-core/src/main/java/io/hawt/config/ConfigFacade.java | ConfigFacade.getConfigDirectory | public File getConfigDirectory() {
String dirName = getConfigDir();
File answer = null;
if (Strings.isNotBlank(dirName)) {
answer = new File(dirName);
} else {
answer = new File(".hawtio");
}
answer.mkdirs();
return answer;
} | java | public File getConfigDirectory() {
String dirName = getConfigDir();
File answer = null;
if (Strings.isNotBlank(dirName)) {
answer = new File(dirName);
} else {
answer = new File(".hawtio");
}
answer.mkdirs();
return answer;
} | [
"public",
"File",
"getConfigDirectory",
"(",
")",
"{",
"String",
"dirName",
"=",
"getConfigDir",
"(",
")",
";",
"File",
"answer",
"=",
"null",
";",
"if",
"(",
"Strings",
".",
"isNotBlank",
"(",
"dirName",
")",
")",
"{",
"answer",
"=",
"new",
"File",
"(... | Returns the configuration directory; lazily attempting to create it if it does not yet exist | [
"Returns",
"the",
"configuration",
"directory",
";",
"lazily",
"attempting",
"to",
"create",
"it",
"if",
"it",
"does",
"not",
"yet",
"exist"
] | d8b1c8f246307c0313ba297a494106d0859f3ffd | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-core/src/main/java/io/hawt/config/ConfigFacade.java#L57-L67 | train |
hawtio/hawtio | hawtio-log/src/main/java/io/hawt/log/support/LogQuerySupport.java | LogQuerySupport.start | public void start() {
MBeanServer server = getMbeanServer();
if (server != null) {
registerMBeanServer(server);
} else {
LOG.error("No MBeanServer available so cannot register mbean");
}
} | java | public void start() {
MBeanServer server = getMbeanServer();
if (server != null) {
registerMBeanServer(server);
} else {
LOG.error("No MBeanServer available so cannot register mbean");
}
} | [
"public",
"void",
"start",
"(",
")",
"{",
"MBeanServer",
"server",
"=",
"getMbeanServer",
"(",
")",
";",
"if",
"(",
"server",
"!=",
"null",
")",
"{",
"registerMBeanServer",
"(",
"server",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"error",
"(",
"\"No MBea... | Registers the object with JMX | [
"Registers",
"the",
"object",
"with",
"JMX"
] | d8b1c8f246307c0313ba297a494106d0859f3ffd | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-log/src/main/java/io/hawt/log/support/LogQuerySupport.java#L71-L78 | train |
hawtio/hawtio | hawtio-local-jvm-mbean/src/main/java/io/hawt/jvm/local/JVMList.java | JVMList.checkAgentUrl | protected String checkAgentUrl(Object pVm) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Properties systemProperties = getAgentSystemProperties(pVm);
return systemProperties.getProperty(JvmAgent.JOLOKIA_AGENT_URL);
} | java | protected String checkAgentUrl(Object pVm) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Properties systemProperties = getAgentSystemProperties(pVm);
return systemProperties.getProperty(JvmAgent.JOLOKIA_AGENT_URL);
} | [
"protected",
"String",
"checkAgentUrl",
"(",
"Object",
"pVm",
")",
"throws",
"NoSuchMethodException",
",",
"InvocationTargetException",
",",
"IllegalAccessException",
"{",
"Properties",
"systemProperties",
"=",
"getAgentSystemProperties",
"(",
"pVm",
")",
";",
"return",
... | borrowed these from AbstractBaseCommand for now | [
"borrowed",
"these",
"from",
"AbstractBaseCommand",
"for",
"now"
] | d8b1c8f246307c0313ba297a494106d0859f3ffd | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-local-jvm-mbean/src/main/java/io/hawt/jvm/local/JVMList.java#L276-L279 | train |
hawtio/hawtio | hawtio-system/src/main/java/io/hawt/web/proxy/ProxyDetails.java | ProxyDetails.indexOf | protected int indexOf(String text, String... values) {
int answer = -1;
for (String value : values) {
int idx = text.indexOf(value);
if (idx >= 0) {
if (answer < 0 || idx < answer) {
answer = idx;
}
}
}
return answer;
} | java | protected int indexOf(String text, String... values) {
int answer = -1;
for (String value : values) {
int idx = text.indexOf(value);
if (idx >= 0) {
if (answer < 0 || idx < answer) {
answer = idx;
}
}
}
return answer;
} | [
"protected",
"int",
"indexOf",
"(",
"String",
"text",
",",
"String",
"...",
"values",
")",
"{",
"int",
"answer",
"=",
"-",
"1",
";",
"for",
"(",
"String",
"value",
":",
"values",
")",
"{",
"int",
"idx",
"=",
"text",
".",
"indexOf",
"(",
"value",
")... | Returns the lowest index of the given list of values | [
"Returns",
"the",
"lowest",
"index",
"of",
"the",
"given",
"list",
"of",
"values"
] | d8b1c8f246307c0313ba297a494106d0859f3ffd | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-system/src/main/java/io/hawt/web/proxy/ProxyDetails.java#L195-L206 | train |
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/FileLocker.java | FileLocker.getLock | public static FileLocker getLock(File lockFile) {
lockFile.getParentFile().mkdirs();
if (!lockFile.exists()) {
try {
IOHelper.write(lockFile, "I have the lock!");
lockFile.deleteOnExit();
return new FileLocker(lockFile);
} catch (IOException e) {
// Ignore
}
}
return null;
} | java | public static FileLocker getLock(File lockFile) {
lockFile.getParentFile().mkdirs();
if (!lockFile.exists()) {
try {
IOHelper.write(lockFile, "I have the lock!");
lockFile.deleteOnExit();
return new FileLocker(lockFile);
} catch (IOException e) {
// Ignore
}
}
return null;
} | [
"public",
"static",
"FileLocker",
"getLock",
"(",
"File",
"lockFile",
")",
"{",
"lockFile",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
";",
"if",
"(",
"!",
"lockFile",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"IOHelper",
".",
"wri... | Attempts to grab the lock for the given file, returning a FileLock if
the lock has been created; otherwise it returns null | [
"Attempts",
"to",
"grab",
"the",
"lock",
"for",
"the",
"given",
"file",
"returning",
"a",
"FileLock",
"if",
"the",
"lock",
"has",
"been",
"created",
";",
"otherwise",
"it",
"returns",
"null"
] | d8b1c8f246307c0313ba297a494106d0859f3ffd | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/FileLocker.java#L16-L29 | train |
hawtio/hawtio | hawtio-util/src/main/java/io/hawt/util/Objects.java | Objects.getVersion | public static String getVersion(Class<?> aClass, String groupId, String artifactId) {
String version = null;
// lets try find the maven property - as the Java API rarely works :)
InputStream is = null;
String fileName = "/META-INF/maven/" +
groupId + "/" + artifactId +
"/pom.properties";
// try to load from maven properties first
try {
Properties p = new Properties();
is = aClass.getResourceAsStream(fileName);
if (is != null) {
p.load(is);
version = p.getProperty("version", "");
}
} catch (Exception e) {
// ignore
} finally {
if (is != null) {
IOHelper.close(is, fileName, LOG);
}
}
if (version == null) {
Package aPackage = aClass.getPackage();
if (aPackage != null) {
version = aPackage.getImplementationVersion();
if (Strings.isBlank(version)) {
version = aPackage.getSpecificationVersion();
}
}
}
if (version == null) {
Enumeration<URL> resources = null;
try {
resources = aClass.getClassLoader().getResources("META-INF/MANIFEST.MF");
} catch (IOException e) {
// ignore
}
if (resources != null) {
String expectedBundleName = groupId + "." + artifactId;
while (resources.hasMoreElements()) {
try {
Manifest manifest = new Manifest(resources.nextElement().openStream());
Attributes attributes = manifest.getMainAttributes();
String bundleName = attributes.getValue("Bundle-SymbolicName");
if (Objects.equals(expectedBundleName, bundleName)) {
version = attributes.getValue("Implementation-Version");
if (Strings.isNotBlank(version)) break;
}
} catch (IOException e) {
// ignore
}
}
}
}
return version;
} | java | public static String getVersion(Class<?> aClass, String groupId, String artifactId) {
String version = null;
// lets try find the maven property - as the Java API rarely works :)
InputStream is = null;
String fileName = "/META-INF/maven/" +
groupId + "/" + artifactId +
"/pom.properties";
// try to load from maven properties first
try {
Properties p = new Properties();
is = aClass.getResourceAsStream(fileName);
if (is != null) {
p.load(is);
version = p.getProperty("version", "");
}
} catch (Exception e) {
// ignore
} finally {
if (is != null) {
IOHelper.close(is, fileName, LOG);
}
}
if (version == null) {
Package aPackage = aClass.getPackage();
if (aPackage != null) {
version = aPackage.getImplementationVersion();
if (Strings.isBlank(version)) {
version = aPackage.getSpecificationVersion();
}
}
}
if (version == null) {
Enumeration<URL> resources = null;
try {
resources = aClass.getClassLoader().getResources("META-INF/MANIFEST.MF");
} catch (IOException e) {
// ignore
}
if (resources != null) {
String expectedBundleName = groupId + "." + artifactId;
while (resources.hasMoreElements()) {
try {
Manifest manifest = new Manifest(resources.nextElement().openStream());
Attributes attributes = manifest.getMainAttributes();
String bundleName = attributes.getValue("Bundle-SymbolicName");
if (Objects.equals(expectedBundleName, bundleName)) {
version = attributes.getValue("Implementation-Version");
if (Strings.isNotBlank(version)) break;
}
} catch (IOException e) {
// ignore
}
}
}
}
return version;
} | [
"public",
"static",
"String",
"getVersion",
"(",
"Class",
"<",
"?",
">",
"aClass",
",",
"String",
"groupId",
",",
"String",
"artifactId",
")",
"{",
"String",
"version",
"=",
"null",
";",
"// lets try find the maven property - as the Java API rarely works :)",
"InputSt... | Returns the version of the given class's package or the group and artifact of the jar | [
"Returns",
"the",
"version",
"of",
"the",
"given",
"class",
"s",
"package",
"or",
"the",
"group",
"and",
"artifact",
"of",
"the",
"jar"
] | d8b1c8f246307c0313ba297a494106d0859f3ffd | https://github.com/hawtio/hawtio/blob/d8b1c8f246307c0313ba297a494106d0859f3ffd/hawtio-util/src/main/java/io/hawt/util/Objects.java#L63-L119 | train |
stripe/stripe-android | stripe/src/main/java/com/stripe/android/view/CardMultilineWidget.java | CardMultilineWidget.clear | public void clear() {
mCardNumberEditText.setText("");
mExpiryDateEditText.setText("");
mCvcEditText.setText("");
mPostalCodeEditText.setText("");
mCardNumberEditText.setShouldShowError(false);
mExpiryDateEditText.setShouldShowError(false);
mCvcEditText.setShouldShowError(false);
mPostalCodeEditText.setShouldShowError(false);
updateBrand(Card.UNKNOWN);
} | java | public void clear() {
mCardNumberEditText.setText("");
mExpiryDateEditText.setText("");
mCvcEditText.setText("");
mPostalCodeEditText.setText("");
mCardNumberEditText.setShouldShowError(false);
mExpiryDateEditText.setShouldShowError(false);
mCvcEditText.setShouldShowError(false);
mPostalCodeEditText.setShouldShowError(false);
updateBrand(Card.UNKNOWN);
} | [
"public",
"void",
"clear",
"(",
")",
"{",
"mCardNumberEditText",
".",
"setText",
"(",
"\"\"",
")",
";",
"mExpiryDateEditText",
".",
"setText",
"(",
"\"\"",
")",
";",
"mCvcEditText",
".",
"setText",
"(",
"\"\"",
")",
";",
"mPostalCodeEditText",
".",
"setText"... | Clear all entered data and hide all error messages. | [
"Clear",
"all",
"entered",
"data",
"and",
"hide",
"all",
"error",
"messages",
"."
] | 0f199255f3769a3b84583fe3ace47bfae8c3b1c8 | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/view/CardMultilineWidget.java#L94-L104 | train |
stripe/stripe-android | stripe/src/main/java/com/stripe/android/view/CardMultilineWidget.java | CardMultilineWidget.validateCardNumber | public boolean validateCardNumber() {
boolean cardNumberIsValid =
CardUtils.isValidCardNumber(mCardNumberEditText.getCardNumber());
mCardNumberEditText.setShouldShowError(!cardNumberIsValid);
return cardNumberIsValid;
} | java | public boolean validateCardNumber() {
boolean cardNumberIsValid =
CardUtils.isValidCardNumber(mCardNumberEditText.getCardNumber());
mCardNumberEditText.setShouldShowError(!cardNumberIsValid);
return cardNumberIsValid;
} | [
"public",
"boolean",
"validateCardNumber",
"(",
")",
"{",
"boolean",
"cardNumberIsValid",
"=",
"CardUtils",
".",
"isValidCardNumber",
"(",
"mCardNumberEditText",
".",
"getCardNumber",
"(",
")",
")",
";",
"mCardNumberEditText",
".",
"setShouldShowError",
"(",
"!",
"c... | Checks whether the current card number is valid | [
"Checks",
"whether",
"the",
"current",
"card",
"number",
"is",
"valid"
] | 0f199255f3769a3b84583fe3ace47bfae8c3b1c8 | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/view/CardMultilineWidget.java#L200-L205 | train |
stripe/stripe-android | stripe/src/main/java/com/stripe/android/view/CardInputWidget.java | CardInputWidget.setExpiryDate | public void setExpiryDate(
@IntRange(from = 1, to = 12) int month,
@IntRange(from = 0, to = 9999) int year) {
mExpiryDateEditText.setText(DateUtils.createDateStringFromIntegerInput(month, year));
} | java | public void setExpiryDate(
@IntRange(from = 1, to = 12) int month,
@IntRange(from = 0, to = 9999) int year) {
mExpiryDateEditText.setText(DateUtils.createDateStringFromIntegerInput(month, year));
} | [
"public",
"void",
"setExpiryDate",
"(",
"@",
"IntRange",
"(",
"from",
"=",
"1",
",",
"to",
"=",
"12",
")",
"int",
"month",
",",
"@",
"IntRange",
"(",
"from",
"=",
"0",
",",
"to",
"=",
"9999",
")",
"int",
"year",
")",
"{",
"mExpiryDateEditText",
"."... | Set the expiration date. Method invokes completion listener and changes focus
to the CVC field if a valid date is entered.
Note that while a four-digit and two-digit year will both work, information
beyond the tens digit of a year will be truncated. Logic elsewhere in the SDK
makes assumptions about what century is implied by various two-digit years, and
will override any information provided here.
@param month a month of the year, represented as a number between 1 and 12
@param year a year number, either in two-digit form or four-digit form | [
"Set",
"the",
"expiration",
"date",
".",
"Method",
"invokes",
"completion",
"listener",
"and",
"changes",
"focus",
"to",
"the",
"CVC",
"field",
"if",
"a",
"valid",
"date",
"is",
"entered",
"."
] | 0f199255f3769a3b84583fe3ace47bfae8c3b1c8 | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/view/CardInputWidget.java#L165-L169 | train |
stripe/stripe-android | stripe/src/main/java/com/stripe/android/view/CardInputWidget.java | CardInputWidget.clear | public void clear() {
if (mCardNumberEditText.hasFocus()
|| mExpiryDateEditText.hasFocus()
|| mCvcNumberEditText.hasFocus()
|| this.hasFocus()) {
mCardNumberEditText.requestFocus();
}
mCvcNumberEditText.setText("");
mExpiryDateEditText.setText("");
mCardNumberEditText.setText("");
} | java | public void clear() {
if (mCardNumberEditText.hasFocus()
|| mExpiryDateEditText.hasFocus()
|| mCvcNumberEditText.hasFocus()
|| this.hasFocus()) {
mCardNumberEditText.requestFocus();
}
mCvcNumberEditText.setText("");
mExpiryDateEditText.setText("");
mCardNumberEditText.setText("");
} | [
"public",
"void",
"clear",
"(",
")",
"{",
"if",
"(",
"mCardNumberEditText",
".",
"hasFocus",
"(",
")",
"||",
"mExpiryDateEditText",
".",
"hasFocus",
"(",
")",
"||",
"mCvcNumberEditText",
".",
"hasFocus",
"(",
")",
"||",
"this",
".",
"hasFocus",
"(",
")",
... | Clear all text fields in the CardInputWidget. | [
"Clear",
"all",
"text",
"fields",
"in",
"the",
"CardInputWidget",
"."
] | 0f199255f3769a3b84583fe3ace47bfae8c3b1c8 | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/view/CardInputWidget.java#L184-L194 | train |
stripe/stripe-android | stripe/src/main/java/com/stripe/android/view/CardInputWidget.java | CardInputWidget.setEnabled | public void setEnabled(boolean isEnabled) {
mCardNumberEditText.setEnabled(isEnabled);
mExpiryDateEditText.setEnabled(isEnabled);
mCvcNumberEditText.setEnabled(isEnabled);
} | java | public void setEnabled(boolean isEnabled) {
mCardNumberEditText.setEnabled(isEnabled);
mExpiryDateEditText.setEnabled(isEnabled);
mCvcNumberEditText.setEnabled(isEnabled);
} | [
"public",
"void",
"setEnabled",
"(",
"boolean",
"isEnabled",
")",
"{",
"mCardNumberEditText",
".",
"setEnabled",
"(",
"isEnabled",
")",
";",
"mExpiryDateEditText",
".",
"setEnabled",
"(",
"isEnabled",
")",
";",
"mCvcNumberEditText",
".",
"setEnabled",
"(",
"isEnab... | Enable or disable text fields
@param isEnabled boolean indicating whether fields should be enabled | [
"Enable",
"or",
"disable",
"text",
"fields"
] | 0f199255f3769a3b84583fe3ace47bfae8c3b1c8 | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/view/CardInputWidget.java#L201-L205 | train |
stripe/stripe-android | stripe/src/main/java/com/stripe/android/view/StripeEditText.java | StripeEditText.setHintDelayed | public void setHintDelayed(@StringRes final int hintResource, long delayMilliseconds) {
final Runnable hintRunnable = new Runnable() {
@Override
public void run() {
setHint(hintResource);
}
};
mHandler.postDelayed(hintRunnable, delayMilliseconds);
} | java | public void setHintDelayed(@StringRes final int hintResource, long delayMilliseconds) {
final Runnable hintRunnable = new Runnable() {
@Override
public void run() {
setHint(hintResource);
}
};
mHandler.postDelayed(hintRunnable, delayMilliseconds);
} | [
"public",
"void",
"setHintDelayed",
"(",
"@",
"StringRes",
"final",
"int",
"hintResource",
",",
"long",
"delayMilliseconds",
")",
"{",
"final",
"Runnable",
"hintRunnable",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
... | Change the hint value of this control after a delay.
@param hintResource the string resource for the hint to be set
@param delayMilliseconds a delay period, measured in milliseconds | [
"Change",
"the",
"hint",
"value",
"of",
"this",
"control",
"after",
"a",
"delay",
"."
] | 0f199255f3769a3b84583fe3ace47bfae8c3b1c8 | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/view/StripeEditText.java#L140-L148 | train |
stripe/stripe-android | stripe/src/main/java/com/stripe/android/view/StripeEditText.java | StripeEditText.setShouldShowError | public void setShouldShowError(boolean shouldShowError) {
if (mErrorMessage != null && mErrorMessageListener != null) {
String errorMessage = shouldShowError ? mErrorMessage : null;
mErrorMessageListener.displayErrorMessage(errorMessage);
mShouldShowError = shouldShowError;
} else {
mShouldShowError = shouldShowError;
if (mShouldShowError) {
setTextColor(mErrorColor);
} else {
setTextColor(mCachedColorStateList);
}
refreshDrawableState();
}
} | java | public void setShouldShowError(boolean shouldShowError) {
if (mErrorMessage != null && mErrorMessageListener != null) {
String errorMessage = shouldShowError ? mErrorMessage : null;
mErrorMessageListener.displayErrorMessage(errorMessage);
mShouldShowError = shouldShowError;
} else {
mShouldShowError = shouldShowError;
if (mShouldShowError) {
setTextColor(mErrorColor);
} else {
setTextColor(mCachedColorStateList);
}
refreshDrawableState();
}
} | [
"public",
"void",
"setShouldShowError",
"(",
"boolean",
"shouldShowError",
")",
"{",
"if",
"(",
"mErrorMessage",
"!=",
"null",
"&&",
"mErrorMessageListener",
"!=",
"null",
")",
"{",
"String",
"errorMessage",
"=",
"shouldShowError",
"?",
"mErrorMessage",
":",
"null... | Sets whether or not the text should be put into "error mode," which displays
the text in an error color determined by the original text color.
@param shouldShowError whether or not we should display text in an error state. | [
"Sets",
"whether",
"or",
"not",
"the",
"text",
"should",
"be",
"put",
"into",
"error",
"mode",
"which",
"displays",
"the",
"text",
"in",
"an",
"error",
"color",
"determined",
"by",
"the",
"original",
"text",
"color",
"."
] | 0f199255f3769a3b84583fe3ace47bfae8c3b1c8 | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/view/StripeEditText.java#L156-L171 | train |
stripe/stripe-android | example/src/main/java/com/stripe/example/activity/RedirectActivity.java | RedirectActivity.showDialog | private void showDialog(@NonNull final Source source) {
// Caching the source object here because this app makes a lot of them.
mRedirectSource = source;
final SourceRedirect sourceRedirect = source.getRedirect();
final String redirectUrl = sourceRedirect != null ? sourceRedirect.getUrl() : null;
if (redirectUrl != null) {
mRedirectDialogController.showDialog(redirectUrl);
}
} | java | private void showDialog(@NonNull final Source source) {
// Caching the source object here because this app makes a lot of them.
mRedirectSource = source;
final SourceRedirect sourceRedirect = source.getRedirect();
final String redirectUrl = sourceRedirect != null ? sourceRedirect.getUrl() : null;
if (redirectUrl != null) {
mRedirectDialogController.showDialog(redirectUrl);
}
} | [
"private",
"void",
"showDialog",
"(",
"@",
"NonNull",
"final",
"Source",
"source",
")",
"{",
"// Caching the source object here because this app makes a lot of them.",
"mRedirectSource",
"=",
"source",
";",
"final",
"SourceRedirect",
"sourceRedirect",
"=",
"source",
".",
... | Show a dialog with a link to the external verification site.
@param source the {@link Source} to verify | [
"Show",
"a",
"dialog",
"with",
"a",
"link",
"to",
"the",
"external",
"verification",
"site",
"."
] | 0f199255f3769a3b84583fe3ace47bfae8c3b1c8 | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/example/src/main/java/com/stripe/example/activity/RedirectActivity.java#L259-L268 | train |
stripe/stripe-android | samplestore/src/main/java/com/stripe/samplestore/StoreActivity.java | StoreActivity.handlePostAuthReturn | private void handlePostAuthReturn() {
final Uri intentUri = getIntent().getData();
if (intentUri != null) {
if ("stripe".equals(intentUri.getScheme()) &&
"payment-auth-return".equals(intentUri.getHost())) {
final String paymentIntentClientSecret =
intentUri.getQueryParameter("payment_intent_client_secret");
if (paymentIntentClientSecret != null) {
final Stripe stripe = new Stripe(getApplicationContext(),
PaymentConfiguration.getInstance().getPublishableKey());
final PaymentIntentParams paymentIntentParams = PaymentIntentParams
.createRetrievePaymentIntentParams(paymentIntentClientSecret);
mCompositeDisposable.add(Observable
.fromCallable(() ->
stripe.retrievePaymentIntentSynchronous(paymentIntentParams,
PaymentConfiguration.getInstance().getPublishableKey()))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe((paymentIntent -> {
if (paymentIntent != null) {
handleRetrievedPaymentIntent(paymentIntent);
}
}))
);
}
}
}
} | java | private void handlePostAuthReturn() {
final Uri intentUri = getIntent().getData();
if (intentUri != null) {
if ("stripe".equals(intentUri.getScheme()) &&
"payment-auth-return".equals(intentUri.getHost())) {
final String paymentIntentClientSecret =
intentUri.getQueryParameter("payment_intent_client_secret");
if (paymentIntentClientSecret != null) {
final Stripe stripe = new Stripe(getApplicationContext(),
PaymentConfiguration.getInstance().getPublishableKey());
final PaymentIntentParams paymentIntentParams = PaymentIntentParams
.createRetrievePaymentIntentParams(paymentIntentClientSecret);
mCompositeDisposable.add(Observable
.fromCallable(() ->
stripe.retrievePaymentIntentSynchronous(paymentIntentParams,
PaymentConfiguration.getInstance().getPublishableKey()))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe((paymentIntent -> {
if (paymentIntent != null) {
handleRetrievedPaymentIntent(paymentIntent);
}
}))
);
}
}
}
} | [
"private",
"void",
"handlePostAuthReturn",
"(",
")",
"{",
"final",
"Uri",
"intentUri",
"=",
"getIntent",
"(",
")",
".",
"getData",
"(",
")",
";",
"if",
"(",
"intentUri",
"!=",
"null",
")",
"{",
"if",
"(",
"\"stripe\"",
".",
"equals",
"(",
"intentUri",
... | If the intent URI matches the post auth deep-link URI, the user attempted to authenticate
payment and was returned to the app. Retrieve the PaymentIntent and inform the user about
the state of their payment. | [
"If",
"the",
"intent",
"URI",
"matches",
"the",
"post",
"auth",
"deep",
"-",
"link",
"URI",
"the",
"user",
"attempted",
"to",
"authenticate",
"payment",
"and",
"was",
"returned",
"to",
"the",
"app",
".",
"Retrieve",
"the",
"PaymentIntent",
"and",
"inform",
... | 0f199255f3769a3b84583fe3ace47bfae8c3b1c8 | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/samplestore/src/main/java/com/stripe/samplestore/StoreActivity.java#L117-L144 | train |
stripe/stripe-android | stripe/src/main/java/com/stripe/android/view/DateUtils.java | DateUtils.separateDateStringParts | @Size(2)
@NonNull
static String[] separateDateStringParts(@NonNull @Size(max = 4) String expiryInput) {
String[] parts = new String[2];
if (expiryInput.length() >= 2) {
parts[0] = expiryInput.substring(0, 2);
parts[1] = expiryInput.substring(2);
} else {
parts[0] = expiryInput;
parts[1] = "";
}
return parts;
} | java | @Size(2)
@NonNull
static String[] separateDateStringParts(@NonNull @Size(max = 4) String expiryInput) {
String[] parts = new String[2];
if (expiryInput.length() >= 2) {
parts[0] = expiryInput.substring(0, 2);
parts[1] = expiryInput.substring(2);
} else {
parts[0] = expiryInput;
parts[1] = "";
}
return parts;
} | [
"@",
"Size",
"(",
"2",
")",
"@",
"NonNull",
"static",
"String",
"[",
"]",
"separateDateStringParts",
"(",
"@",
"NonNull",
"@",
"Size",
"(",
"max",
"=",
"4",
")",
"String",
"expiryInput",
")",
"{",
"String",
"[",
"]",
"parts",
"=",
"new",
"String",
"[... | Separates raw string input of the format MMYY into a "month" group and a "year" group.
Either or both of these may be incomplete. This method does not check to see if the input
is valid.
@param expiryInput up to four characters of user input
@return a length-2 array containing the first two characters in the 0 index, and the last
two characters in the 1 index. "123" gets split into {"12" , "3"}, and "1" becomes {"1", ""}. | [
"Separates",
"raw",
"string",
"input",
"of",
"the",
"format",
"MMYY",
"into",
"a",
"month",
"group",
"and",
"a",
"year",
"group",
".",
"Either",
"or",
"both",
"of",
"these",
"may",
"be",
"incomplete",
".",
"This",
"method",
"does",
"not",
"check",
"to",
... | 0f199255f3769a3b84583fe3ace47bfae8c3b1c8 | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/view/DateUtils.java#L44-L56 | train |
stripe/stripe-android | stripe/src/main/java/com/stripe/android/view/DateUtils.java | DateUtils.convertTwoDigitYearToFour | @IntRange(from = 1000, to = 9999)
static int convertTwoDigitYearToFour(@IntRange(from = 0, to = 99) int inputYear) {
return convertTwoDigitYearToFour(inputYear, Calendar.getInstance());
} | java | @IntRange(from = 1000, to = 9999)
static int convertTwoDigitYearToFour(@IntRange(from = 0, to = 99) int inputYear) {
return convertTwoDigitYearToFour(inputYear, Calendar.getInstance());
} | [
"@",
"IntRange",
"(",
"from",
"=",
"1000",
",",
"to",
"=",
"9999",
")",
"static",
"int",
"convertTwoDigitYearToFour",
"(",
"@",
"IntRange",
"(",
"from",
"=",
"0",
",",
"to",
"=",
"99",
")",
"int",
"inputYear",
")",
"{",
"return",
"convertTwoDigitYearToFo... | Converts a two-digit input year to a four-digit year. As the current calendar year
approaches a century, we assume small values to mean the next century. For instance, if
the current year is 2090, and the input value is "18", the user probably means 2118,
not 2018. However, in 2017, the input "18" probably means 2018. This code should be
updated before the year 9981.
@param inputYear a two-digit integer, between 0 and 99, inclusive
@return a four-digit year | [
"Converts",
"a",
"two",
"-",
"digit",
"input",
"year",
"to",
"a",
"four",
"-",
"digit",
"year",
".",
"As",
"the",
"current",
"calendar",
"year",
"approaches",
"a",
"century",
"we",
"assume",
"small",
"values",
"to",
"mean",
"the",
"next",
"century",
".",... | 0f199255f3769a3b84583fe3ace47bfae8c3b1c8 | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/view/DateUtils.java#L143-L146 | train |
stripe/stripe-android | stripe/src/main/java/com/stripe/android/model/SourceParams.java | SourceParams.createSourceFromTokenParams | @NonNull
public static SourceParams createSourceFromTokenParams(String tokenId) {
SourceParams sourceParams = SourceParams.createCustomParams();
sourceParams.setType(Source.CARD);
sourceParams.setToken(tokenId);
return sourceParams;
} | java | @NonNull
public static SourceParams createSourceFromTokenParams(String tokenId) {
SourceParams sourceParams = SourceParams.createCustomParams();
sourceParams.setType(Source.CARD);
sourceParams.setToken(tokenId);
return sourceParams;
} | [
"@",
"NonNull",
"public",
"static",
"SourceParams",
"createSourceFromTokenParams",
"(",
"String",
"tokenId",
")",
"{",
"SourceParams",
"sourceParams",
"=",
"SourceParams",
".",
"createCustomParams",
"(",
")",
";",
"sourceParams",
".",
"setType",
"(",
"Source",
".",
... | Create parameters necessary for converting a token into a source
@param tokenId the id of the {@link Token} to be converted into a source.
@return a {@link SourceParams} object that can be used to create a source. | [
"Create",
"parameters",
"necessary",
"for",
"converting",
"a",
"token",
"into",
"a",
"source"
] | 0f199255f3769a3b84583fe3ace47bfae8c3b1c8 | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/model/SourceParams.java#L248-L254 | train |
stripe/stripe-android | stripe/src/main/java/com/stripe/android/model/SourceParams.java | SourceParams.createRetrieveSourceParams | @NonNull
public static Map<String, Object> createRetrieveSourceParams(
@NonNull @Size(min = 1) String clientSecret) {
final Map<String, Object> params = new HashMap<>();
params.put(API_PARAM_CLIENT_SECRET, clientSecret);
return params;
} | java | @NonNull
public static Map<String, Object> createRetrieveSourceParams(
@NonNull @Size(min = 1) String clientSecret) {
final Map<String, Object> params = new HashMap<>();
params.put(API_PARAM_CLIENT_SECRET, clientSecret);
return params;
} | [
"@",
"NonNull",
"public",
"static",
"Map",
"<",
"String",
",",
"Object",
">",
"createRetrieveSourceParams",
"(",
"@",
"NonNull",
"@",
"Size",
"(",
"min",
"=",
"1",
")",
"String",
"clientSecret",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Object",
">"... | Create parameters needed to retrieve a source.
@param clientSecret the client secret for the source, needed because the Android SDK uses
a public key
@return a {@link Map} matching the parameter name to the client secret, ready to send to
the server. | [
"Create",
"parameters",
"needed",
"to",
"retrieve",
"a",
"source",
"."
] | 0f199255f3769a3b84583fe3ace47bfae8c3b1c8 | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/stripe/src/main/java/com/stripe/android/model/SourceParams.java#L608-L614 | train |
stripe/stripe-android | example/src/main/java/com/stripe/example/module/DependencyHandler.java | DependencyHandler.clearReferences | public void clearReferences() {
if (mAsyncTaskController != null) {
mAsyncTaskController.detach();
}
if (mRxTokenController != null) {
mRxTokenController.detach();
}
if (mIntentServiceTokenController != null) {
mIntentServiceTokenController.detach();
}
mAsyncTaskController = null;
mRxTokenController = null;
mIntentServiceTokenController = null;
} | java | public void clearReferences() {
if (mAsyncTaskController != null) {
mAsyncTaskController.detach();
}
if (mRxTokenController != null) {
mRxTokenController.detach();
}
if (mIntentServiceTokenController != null) {
mIntentServiceTokenController.detach();
}
mAsyncTaskController = null;
mRxTokenController = null;
mIntentServiceTokenController = null;
} | [
"public",
"void",
"clearReferences",
"(",
")",
"{",
"if",
"(",
"mAsyncTaskController",
"!=",
"null",
")",
"{",
"mAsyncTaskController",
".",
"detach",
"(",
")",
";",
"}",
"if",
"(",
"mRxTokenController",
"!=",
"null",
")",
"{",
"mRxTokenController",
".",
"det... | Clear all the references so that we can start over again. | [
"Clear",
"all",
"the",
"references",
"so",
"that",
"we",
"can",
"start",
"over",
"again",
"."
] | 0f199255f3769a3b84583fe3ace47bfae8c3b1c8 | https://github.com/stripe/stripe-android/blob/0f199255f3769a3b84583fe3ace47bfae8c3b1c8/example/src/main/java/com/stripe/example/module/DependencyHandler.java#L125-L142 | train |
playn/playn | core/src/playn/core/Surface.java | Surface.rotate | public Surface rotate (float angle) {
float sr = (float) Math.sin(angle);
float cr = (float) Math.cos(angle);
transform(cr, sr, -sr, cr, 0, 0);
return this;
} | java | public Surface rotate (float angle) {
float sr = (float) Math.sin(angle);
float cr = (float) Math.cos(angle);
transform(cr, sr, -sr, cr, 0, 0);
return this;
} | [
"public",
"Surface",
"rotate",
"(",
"float",
"angle",
")",
"{",
"float",
"sr",
"=",
"(",
"float",
")",
"Math",
".",
"sin",
"(",
"angle",
")",
";",
"float",
"cr",
"=",
"(",
"float",
")",
"Math",
".",
"cos",
"(",
"angle",
")",
";",
"transform",
"("... | Rotates the current transformation matrix by the specified angle in radians. | [
"Rotates",
"the",
"current",
"transformation",
"matrix",
"by",
"the",
"specified",
"angle",
"in",
"radians",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Surface.java#L168-L173 | train |
playn/playn | core/src/playn/core/Surface.java | Surface.transform | public Surface transform (float m00, float m01, float m10, float m11, float tx, float ty) {
AffineTransform top = tx();
Transforms.multiply(top, m00, m01, m10, m11, tx, ty, top);
return this;
} | java | public Surface transform (float m00, float m01, float m10, float m11, float tx, float ty) {
AffineTransform top = tx();
Transforms.multiply(top, m00, m01, m10, m11, tx, ty, top);
return this;
} | [
"public",
"Surface",
"transform",
"(",
"float",
"m00",
",",
"float",
"m01",
",",
"float",
"m10",
",",
"float",
"m11",
",",
"float",
"tx",
",",
"float",
"ty",
")",
"{",
"AffineTransform",
"top",
"=",
"tx",
"(",
")",
";",
"Transforms",
".",
"multiply",
... | Multiplies the current transformation matrix by the given matrix. | [
"Multiplies",
"the",
"current",
"transformation",
"matrix",
"by",
"the",
"given",
"matrix",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Surface.java#L176-L180 | train |
playn/playn | core/src/playn/core/Surface.java | Surface.intersects | public boolean intersects (float x, float y, float w, float h) {
tx().transform(intersectionTestPoint.set(x, y), intersectionTestPoint);
tx().transform(intersectionTestSize.set(w, h), intersectionTestSize);
float ix = intersectionTestPoint.x, iy = intersectionTestPoint.y;
float iw = intersectionTestSize.x, ih = intersectionTestSize.y;
if (scissorDepth > 0) {
Rectangle scissor = scissors.get(scissorDepth - 1);
return scissor.intersects((int)ix, (int)iy, (int)iw, (int)ih);
}
float tw = target.width(), th = target.height();
return (ix + iw > 0) && (ix < tw) && (iy + ih > 0) && (iy < th);
} | java | public boolean intersects (float x, float y, float w, float h) {
tx().transform(intersectionTestPoint.set(x, y), intersectionTestPoint);
tx().transform(intersectionTestSize.set(w, h), intersectionTestSize);
float ix = intersectionTestPoint.x, iy = intersectionTestPoint.y;
float iw = intersectionTestSize.x, ih = intersectionTestSize.y;
if (scissorDepth > 0) {
Rectangle scissor = scissors.get(scissorDepth - 1);
return scissor.intersects((int)ix, (int)iy, (int)iw, (int)ih);
}
float tw = target.width(), th = target.height();
return (ix + iw > 0) && (ix < tw) && (iy + ih > 0) && (iy < th);
} | [
"public",
"boolean",
"intersects",
"(",
"float",
"x",
",",
"float",
"y",
",",
"float",
"w",
",",
"float",
"h",
")",
"{",
"tx",
"(",
")",
".",
"transform",
"(",
"intersectionTestPoint",
".",
"set",
"(",
"x",
",",
"y",
")",
",",
"intersectionTestPoint",
... | Returns whether the given rectangle intersects the render target area of this surface. | [
"Returns",
"whether",
"the",
"given",
"rectangle",
"intersects",
"the",
"render",
"target",
"area",
"of",
"this",
"surface",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Surface.java#L258-L271 | train |
playn/playn | core/src/playn/core/Surface.java | Surface.fillRect | public Surface fillRect (float x, float y, float width, float height) {
if (patternTex != null) {
batch.addQuad(patternTex, tint, tx(), x, y, width, height);
} else {
batch.addQuad(colorTex, Tint.combine(fillColor, tint), tx(), x, y, width, height);
}
return this;
} | java | public Surface fillRect (float x, float y, float width, float height) {
if (patternTex != null) {
batch.addQuad(patternTex, tint, tx(), x, y, width, height);
} else {
batch.addQuad(colorTex, Tint.combine(fillColor, tint), tx(), x, y, width, height);
}
return this;
} | [
"public",
"Surface",
"fillRect",
"(",
"float",
"x",
",",
"float",
"y",
",",
"float",
"width",
",",
"float",
"height",
")",
"{",
"if",
"(",
"patternTex",
"!=",
"null",
")",
"{",
"batch",
".",
"addQuad",
"(",
"patternTex",
",",
"tint",
",",
"tx",
"(",
... | Fills the specified rectangle. | [
"Fills",
"the",
"specified",
"rectangle",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Surface.java#L385-L392 | train |
playn/playn | java-lwjgl2/src/playn/java/SharedLibraryExtractor.java | SharedLibraryExtractor.platformNames | private String[] platformNames(String libraryName) {
if (isWindows) return new String[] { libraryName + (is64Bit ? "64.dll" : ".dll") };
if (isLinux) return new String[] { "lib" + libraryName + (is64Bit ? "64.so" : ".so") };
if (isMac) return new String[] { "lib" + libraryName + ".jnilib",
"lib" + libraryName + ".dylib" };
return new String[] { libraryName };
} | java | private String[] platformNames(String libraryName) {
if (isWindows) return new String[] { libraryName + (is64Bit ? "64.dll" : ".dll") };
if (isLinux) return new String[] { "lib" + libraryName + (is64Bit ? "64.so" : ".so") };
if (isMac) return new String[] { "lib" + libraryName + ".jnilib",
"lib" + libraryName + ".dylib" };
return new String[] { libraryName };
} | [
"private",
"String",
"[",
"]",
"platformNames",
"(",
"String",
"libraryName",
")",
"{",
"if",
"(",
"isWindows",
")",
"return",
"new",
"String",
"[",
"]",
"{",
"libraryName",
"+",
"(",
"is64Bit",
"?",
"\"64.dll\"",
":",
"\".dll\"",
")",
"}",
";",
"if",
... | Maps a platform independent library name to one or more platform dependent names. | [
"Maps",
"a",
"platform",
"independent",
"library",
"name",
"to",
"one",
"or",
"more",
"platform",
"dependent",
"names",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/java-lwjgl2/src/playn/java/SharedLibraryExtractor.java#L89-L95 | train |
playn/playn | java-lwjgl2/src/playn/java/SharedLibraryExtractor.java | SharedLibraryExtractor.crc | private String crc(InputStream input) {
if (input == null)
throw new IllegalArgumentException("input cannot be null.");
CRC32 crc = new CRC32();
byte[] buffer = new byte[4096];
try {
while (true) {
int length = input.read(buffer);
if (length == -1) break;
crc.update(buffer, 0, length);
}
} catch (Exception ex) {
try {
input.close();
} catch (Exception ignored) {
}
}
return Long.toString(crc.getValue());
} | java | private String crc(InputStream input) {
if (input == null)
throw new IllegalArgumentException("input cannot be null.");
CRC32 crc = new CRC32();
byte[] buffer = new byte[4096];
try {
while (true) {
int length = input.read(buffer);
if (length == -1) break;
crc.update(buffer, 0, length);
}
} catch (Exception ex) {
try {
input.close();
} catch (Exception ignored) {
}
}
return Long.toString(crc.getValue());
} | [
"private",
"String",
"crc",
"(",
"InputStream",
"input",
")",
"{",
"if",
"(",
"input",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"input cannot be null.\"",
")",
";",
"CRC32",
"crc",
"=",
"new",
"CRC32",
"(",
")",
";",
"byte",
"[... | Returns a CRC of the remaining bytes in the stream. | [
"Returns",
"a",
"CRC",
"of",
"the",
"remaining",
"bytes",
"in",
"the",
"stream",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/java-lwjgl2/src/playn/java/SharedLibraryExtractor.java#L98-L116 | train |
playn/playn | html/src/playn/super/java/nio/CharBuffer.java | CharBuffer.put | public CharBuffer put (String str, int start, int end) {
int length = str.length();
if (start < 0 || end < start || end > length) {
throw new IndexOutOfBoundsException();
}
if (end - start > remaining()) {
throw new BufferOverflowException();
}
for (int i = start; i < end; i++) {
put(str.charAt(i));
}
return this;
} | java | public CharBuffer put (String str, int start, int end) {
int length = str.length();
if (start < 0 || end < start || end > length) {
throw new IndexOutOfBoundsException();
}
if (end - start > remaining()) {
throw new BufferOverflowException();
}
for (int i = start; i < end; i++) {
put(str.charAt(i));
}
return this;
} | [
"public",
"CharBuffer",
"put",
"(",
"String",
"str",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"int",
"length",
"=",
"str",
".",
"length",
"(",
")",
";",
"if",
"(",
"start",
"<",
"0",
"||",
"end",
"<",
"start",
"||",
"end",
">",
"length",... | Writes chars of the given string to the current position of this buffer, and increases the
position by the number of chars written.
@param str the string to write.
@param start the first char to write, must not be negative and not greater than {@code
str.length()}.
@param end the last char to write (excluding), must be less than {@code start} and not
greater than {@code str.length()}.
@return this buffer.
@exception BufferOverflowException if {@code remaining()} is less than {@code end - start}.
@exception IndexOutOfBoundsException if either {@code start} or {@code end} is invalid.
@exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. | [
"Writes",
"chars",
"of",
"the",
"given",
"string",
"to",
"the",
"current",
"position",
"of",
"this",
"buffer",
"and",
"increases",
"the",
"position",
"by",
"the",
"number",
"of",
"chars",
"written",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/super/java/nio/CharBuffer.java#L413-L426 | train |
playn/playn | core/src/playn/core/Net.java | Net.get | public RFuture<String> get(String url) {
return req(url).execute().map(GET_PAYLOAD);
} | java | public RFuture<String> get(String url) {
return req(url).execute().map(GET_PAYLOAD);
} | [
"public",
"RFuture",
"<",
"String",
">",
"get",
"(",
"String",
"url",
")",
"{",
"return",
"req",
"(",
"url",
")",
".",
"execute",
"(",
")",
".",
"map",
"(",
"GET_PAYLOAD",
")",
";",
"}"
] | Performs an HTTP GET request to the specified URL. | [
"Performs",
"an",
"HTTP",
"GET",
"request",
"to",
"the",
"specified",
"URL",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Net.java#L265-L267 | train |
playn/playn | core/src/playn/core/Net.java | Net.post | public RFuture<String> post(String url, String data) {
return req(url).setPayload(data).execute().map(GET_PAYLOAD);
} | java | public RFuture<String> post(String url, String data) {
return req(url).setPayload(data).execute().map(GET_PAYLOAD);
} | [
"public",
"RFuture",
"<",
"String",
">",
"post",
"(",
"String",
"url",
",",
"String",
"data",
")",
"{",
"return",
"req",
"(",
"url",
")",
".",
"setPayload",
"(",
"data",
")",
".",
"execute",
"(",
")",
".",
"map",
"(",
"GET_PAYLOAD",
")",
";",
"}"
] | Performs an HTTP POST request to the specified URL. | [
"Performs",
"an",
"HTTP",
"POST",
"request",
"to",
"the",
"specified",
"URL",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Net.java#L272-L274 | train |
playn/playn | core/src/playn/core/Image.java | Image.region | public Region region (final float rx, final float ry, final float rwidth, final float rheight) {
final Image image = this;
return new Region() {
private Tile tile;
@Override public boolean isLoaded () { return image.isLoaded(); }
@Override public Tile tile () {
if (tile == null) tile = image.texture().tile(rx, ry, rwidth, rheight);
return tile;
}
@Override public RFuture<Tile> tileAsync () {
return image.state.map(new Function<Image,Tile>() {
public Tile apply (Image image) { return tile(); }
});
}
@Override public float width () { return rwidth; }
@Override public float height () { return rheight; }
@Override public void draw (Object ctx, float x, float y, float width, float height) {
image.draw(ctx, x, y, width, height, rx, ry, rwidth, rheight);
}
@Override public void draw (Object ctx, float dx, float dy, float dw, float dh,
float sx, float sy, float sw, float sh) {
image.draw(ctx, dx, dy, dw, dh, rx+sx, ry+sy, sw, sh);
}
};
} | java | public Region region (final float rx, final float ry, final float rwidth, final float rheight) {
final Image image = this;
return new Region() {
private Tile tile;
@Override public boolean isLoaded () { return image.isLoaded(); }
@Override public Tile tile () {
if (tile == null) tile = image.texture().tile(rx, ry, rwidth, rheight);
return tile;
}
@Override public RFuture<Tile> tileAsync () {
return image.state.map(new Function<Image,Tile>() {
public Tile apply (Image image) { return tile(); }
});
}
@Override public float width () { return rwidth; }
@Override public float height () { return rheight; }
@Override public void draw (Object ctx, float x, float y, float width, float height) {
image.draw(ctx, x, y, width, height, rx, ry, rwidth, rheight);
}
@Override public void draw (Object ctx, float dx, float dy, float dw, float dh,
float sx, float sy, float sw, float sh) {
image.draw(ctx, dx, dy, dw, dh, rx+sx, ry+sy, sw, sh);
}
};
} | [
"public",
"Region",
"region",
"(",
"final",
"float",
"rx",
",",
"final",
"float",
"ry",
",",
"final",
"float",
"rwidth",
",",
"final",
"float",
"rheight",
")",
"{",
"final",
"Image",
"image",
"=",
"this",
";",
"return",
"new",
"Region",
"(",
")",
"{",
... | Returns a region of this image which can be drawn independently. | [
"Returns",
"a",
"region",
"of",
"this",
"image",
"which",
"can",
"be",
"drawn",
"independently",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Image.java#L194-L220 | train |
playn/playn | scene/src/playn/scene/CanvasLayer.java | CanvasLayer.resize | public void resize (float width, float height) {
if (canvas != null) canvas.close();
canvas = gfx.createCanvas(width, height);
} | java | public void resize (float width, float height) {
if (canvas != null) canvas.close();
canvas = gfx.createCanvas(width, height);
} | [
"public",
"void",
"resize",
"(",
"float",
"width",
",",
"float",
"height",
")",
"{",
"if",
"(",
"canvas",
"!=",
"null",
")",
"canvas",
".",
"close",
"(",
")",
";",
"canvas",
"=",
"gfx",
".",
"createCanvas",
"(",
"width",
",",
"height",
")",
";",
"}... | Resizes the canvas that is displayed by this layer.
<p>Note: this throws away the old canvas and creates a new blank canvas with the desired size.
Thus this should immediately be followed by a {@link #begin}/{@link #end} pair which updates
the contents of the new canvas. Until then, it will display the old image data. | [
"Resizes",
"the",
"canvas",
"that",
"is",
"displayed",
"by",
"this",
"layer",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/CanvasLayer.java#L71-L74 | train |
playn/playn | scene/src/playn/scene/CanvasLayer.java | CanvasLayer.end | public void end () {
Texture tex = (Texture)tile();
Image image = canvas.image;
// if our texture is already the right size, just update it
if (tex != null && tex.pixelWidth == image.pixelWidth() &&
tex.pixelHeight == image.pixelHeight()) tex.update(image);
// otherwise we need to create a new texture (setTexture will unreference the old texture which
// will cause it to be destroyed)
else super.setTile(canvas.image.createTexture(Texture.Config.DEFAULT));
} | java | public void end () {
Texture tex = (Texture)tile();
Image image = canvas.image;
// if our texture is already the right size, just update it
if (tex != null && tex.pixelWidth == image.pixelWidth() &&
tex.pixelHeight == image.pixelHeight()) tex.update(image);
// otherwise we need to create a new texture (setTexture will unreference the old texture which
// will cause it to be destroyed)
else super.setTile(canvas.image.createTexture(Texture.Config.DEFAULT));
} | [
"public",
"void",
"end",
"(",
")",
"{",
"Texture",
"tex",
"=",
"(",
"Texture",
")",
"tile",
"(",
")",
";",
"Image",
"image",
"=",
"canvas",
".",
"image",
";",
"// if our texture is already the right size, just update it",
"if",
"(",
"tex",
"!=",
"null",
"&&"... | Informs this layer that a drawing operation has just completed. The backing canvas image data
is uploaded to the GPU. | [
"Informs",
"this",
"layer",
"that",
"a",
"drawing",
"operation",
"has",
"just",
"completed",
".",
"The",
"backing",
"canvas",
"image",
"data",
"is",
"uploaded",
"to",
"the",
"GPU",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/CanvasLayer.java#L84-L93 | train |
playn/playn | scene/src/playn/scene/Layer.java | Layer.close | @Override public void close() {
if (parent != null) parent.remove(this);
setState(State.DISPOSED);
setBatch(null);
} | java | @Override public void close() {
if (parent != null) parent.remove(this);
setState(State.DISPOSED);
setBatch(null);
} | [
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"parent",
"!=",
"null",
")",
"parent",
".",
"remove",
"(",
"this",
")",
";",
"setState",
"(",
"State",
".",
"DISPOSED",
")",
";",
"setBatch",
"(",
"null",
")",
";",
"}"
] | Disposes this layer, removing it from its parent layer. Any resources associated with this
layer are freed, and it cannot be reused after being disposed. Disposing a layer that has
children will dispose them as well. | [
"Disposes",
"this",
"layer",
"removing",
"it",
"from",
"its",
"parent",
"layer",
".",
"Any",
"resources",
"associated",
"with",
"this",
"layer",
"are",
"freed",
"and",
"it",
"cannot",
"be",
"reused",
"after",
"being",
"disposed",
".",
"Disposing",
"a",
"laye... | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/Layer.java#L262-L266 | train |
playn/playn | scene/src/playn/scene/Layer.java | Layer.transform | public AffineTransform transform() {
if (isSet(Flag.XFDIRTY)) {
float sina = FloatMath.sin(rotation), cosa = FloatMath.cos(rotation);
float m00 = cosa * scaleX, m01 = sina * scaleX;
float m10 = -sina * scaleY, m11 = cosa * scaleY;
float tx = transform.tx(), ty = transform.ty();
transform.setTransform(m00, m01, m10, m11, tx, ty);
setFlag(Flag.XFDIRTY, false);
}
return transform;
} | java | public AffineTransform transform() {
if (isSet(Flag.XFDIRTY)) {
float sina = FloatMath.sin(rotation), cosa = FloatMath.cos(rotation);
float m00 = cosa * scaleX, m01 = sina * scaleX;
float m10 = -sina * scaleY, m11 = cosa * scaleY;
float tx = transform.tx(), ty = transform.ty();
transform.setTransform(m00, m01, m10, m11, tx, ty);
setFlag(Flag.XFDIRTY, false);
}
return transform;
} | [
"public",
"AffineTransform",
"transform",
"(",
")",
"{",
"if",
"(",
"isSet",
"(",
"Flag",
".",
"XFDIRTY",
")",
")",
"{",
"float",
"sina",
"=",
"FloatMath",
".",
"sin",
"(",
"rotation",
")",
",",
"cosa",
"=",
"FloatMath",
".",
"cos",
"(",
"rotation",
... | Returns the layer's current transformation matrix. If any changes have been made to the
layer's scale, rotation or translation, they will be applied to the transform matrix before it
is returned.
<p><em>Note:</em> any direct modifications to this matrix <em>except</em> modifications to its
translation, will be overwritten if a call is subsequently made to {@link #setScale(float)},
{@link #setScale(float,float)}, {@link #setScaleX}, {@link #setScaleY} or {@link #setRotation}.
If you intend to manipulate a layer's transform matrix directly, <em>do not</em> call those
other methods. Also do not expect {@link #scaleX}, {@link #scaleY}, or {@link #rotation} to
reflect the direct changes you've made to the transform matrix. They will not. </p> | [
"Returns",
"the",
"layer",
"s",
"current",
"transformation",
"matrix",
".",
"If",
"any",
"changes",
"have",
"been",
"made",
"to",
"the",
"layer",
"s",
"scale",
"rotation",
"or",
"translation",
"they",
"will",
"be",
"applied",
"to",
"the",
"transform",
"matri... | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/Layer.java#L280-L290 | train |
playn/playn | scene/src/playn/scene/Layer.java | Layer.originX | public float originX () {
if (isSet(Flag.ODIRTY)) {
float width = width();
if (width > 0) {
this.originX = origin.ox(width);
this.originY = origin.oy(height());
setFlag(Flag.ODIRTY, false);
}
}
return originX;
} | java | public float originX () {
if (isSet(Flag.ODIRTY)) {
float width = width();
if (width > 0) {
this.originX = origin.ox(width);
this.originY = origin.oy(height());
setFlag(Flag.ODIRTY, false);
}
}
return originX;
} | [
"public",
"float",
"originX",
"(",
")",
"{",
"if",
"(",
"isSet",
"(",
"Flag",
".",
"ODIRTY",
")",
")",
"{",
"float",
"width",
"=",
"width",
"(",
")",
";",
"if",
"(",
"width",
">",
"0",
")",
"{",
"this",
".",
"originX",
"=",
"origin",
".",
"ox",... | Returns the x-component of the layer's origin. | [
"Returns",
"the",
"x",
"-",
"component",
"of",
"the",
"layer",
"s",
"origin",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/Layer.java#L348-L358 | train |
playn/playn | scene/src/playn/scene/Layer.java | Layer.originY | public float originY () {
if (isSet(Flag.ODIRTY)) {
float height = height();
if (height > 0) {
this.originX = origin.ox(width());
this.originY = origin.oy(height);
setFlag(Flag.ODIRTY, false);
}
}
return originY;
} | java | public float originY () {
if (isSet(Flag.ODIRTY)) {
float height = height();
if (height > 0) {
this.originX = origin.ox(width());
this.originY = origin.oy(height);
setFlag(Flag.ODIRTY, false);
}
}
return originY;
} | [
"public",
"float",
"originY",
"(",
")",
"{",
"if",
"(",
"isSet",
"(",
"Flag",
".",
"ODIRTY",
")",
")",
"{",
"float",
"height",
"=",
"height",
"(",
")",
";",
"if",
"(",
"height",
">",
"0",
")",
"{",
"this",
".",
"originX",
"=",
"origin",
".",
"o... | Returns the y-component of the layer's origin. | [
"Returns",
"the",
"y",
"-",
"component",
"of",
"the",
"layer",
"s",
"origin",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/Layer.java#L360-L370 | train |
playn/playn | scene/src/playn/scene/Layer.java | Layer.setOrigin | public Layer setOrigin (Origin origin) {
this.origin = origin;
setFlag(Flag.ODIRTY, true);
return this;
} | java | public Layer setOrigin (Origin origin) {
this.origin = origin;
setFlag(Flag.ODIRTY, true);
return this;
} | [
"public",
"Layer",
"setOrigin",
"(",
"Origin",
"origin",
")",
"{",
"this",
".",
"origin",
"=",
"origin",
";",
"setFlag",
"(",
"Flag",
".",
"ODIRTY",
",",
"true",
")",
";",
"return",
"this",
";",
"}"
] | Configures the origin of this layer based on a logical location which is recomputed whenever
the layer changes size.
@return a reference to this layer for call chaining. | [
"Configures",
"the",
"origin",
"of",
"this",
"layer",
"based",
"on",
"a",
"logical",
"location",
"which",
"is",
"recomputed",
"whenever",
"the",
"layer",
"changes",
"size",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/Layer.java#L401-L405 | train |
playn/playn | scene/src/playn/scene/Layer.java | Layer.debugPrint | public void debugPrint(final Log log) {
this.visit(new Visitor() {
public void visit(Layer layer, int depth) {
String prefix = repeat('.', depth);
log.debug(prefix + layer.toString());
}
});
} | java | public void debugPrint(final Log log) {
this.visit(new Visitor() {
public void visit(Layer layer, int depth) {
String prefix = repeat('.', depth);
log.debug(prefix + layer.toString());
}
});
} | [
"public",
"void",
"debugPrint",
"(",
"final",
"Log",
"log",
")",
"{",
"this",
".",
"visit",
"(",
"new",
"Visitor",
"(",
")",
"{",
"public",
"void",
"visit",
"(",
"Layer",
"layer",
",",
"int",
"depth",
")",
"{",
"String",
"prefix",
"=",
"repeat",
"(",... | Prints a debug representation of this layer and its children.
@param log the output will go to this log (at the debug level). | [
"Prints",
"a",
"debug",
"representation",
"of",
"this",
"layer",
"and",
"its",
"children",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/Layer.java#L718-L725 | train |
playn/playn | android/src/playn/android/AndroidAudio.java | AndroidAudio.createSound | public SoundImpl<?> createSound(AssetFileDescriptor fd) {
PooledSound sound = new PooledSound(pool.load(fd, 1));
loadingSounds.put(sound.soundId, sound);
return sound;
} | java | public SoundImpl<?> createSound(AssetFileDescriptor fd) {
PooledSound sound = new PooledSound(pool.load(fd, 1));
loadingSounds.put(sound.soundId, sound);
return sound;
} | [
"public",
"SoundImpl",
"<",
"?",
">",
"createSound",
"(",
"AssetFileDescriptor",
"fd",
")",
"{",
"PooledSound",
"sound",
"=",
"new",
"PooledSound",
"(",
"pool",
".",
"load",
"(",
"fd",
",",
"1",
")",
")",
";",
"loadingSounds",
".",
"put",
"(",
"sound",
... | Creates a sound instance from the supplied asset file descriptor. | [
"Creates",
"a",
"sound",
"instance",
"from",
"the",
"supplied",
"asset",
"file",
"descriptor",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/android/src/playn/android/AndroidAudio.java#L125-L129 | train |
playn/playn | android/src/playn/android/AndroidAudio.java | AndroidAudio.createSound | public SoundImpl<?> createSound(FileDescriptor fd, long offset, long length) {
PooledSound sound = new PooledSound(pool.load(fd, offset, length, 1));
loadingSounds.put(sound.soundId, sound);
return sound;
} | java | public SoundImpl<?> createSound(FileDescriptor fd, long offset, long length) {
PooledSound sound = new PooledSound(pool.load(fd, offset, length, 1));
loadingSounds.put(sound.soundId, sound);
return sound;
} | [
"public",
"SoundImpl",
"<",
"?",
">",
"createSound",
"(",
"FileDescriptor",
"fd",
",",
"long",
"offset",
",",
"long",
"length",
")",
"{",
"PooledSound",
"sound",
"=",
"new",
"PooledSound",
"(",
"pool",
".",
"load",
"(",
"fd",
",",
"offset",
",",
"length"... | Creates a sound instance from the supplied file descriptor offset. | [
"Creates",
"a",
"sound",
"instance",
"from",
"the",
"supplied",
"file",
"descriptor",
"offset",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/android/src/playn/android/AndroidAudio.java#L134-L138 | train |
playn/playn | html/src/playn/super/java/nio/ByteBuffer.java | ByteBuffer.compareTo | public int compareTo (ByteBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ?
remaining() : otherBuffer.remaining();
int thisPos = position;
int otherPos = otherBuffer.position;
byte thisByte, otherByte;
while (compareRemaining > 0) {
thisByte = get(thisPos);
otherByte = otherBuffer.get(otherPos);
if (thisByte != otherByte) {
return thisByte < otherByte ? -1 : 1;
}
thisPos++;
otherPos++;
compareRemaining--;
}
return remaining() - otherBuffer.remaining();
} | java | public int compareTo (ByteBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ?
remaining() : otherBuffer.remaining();
int thisPos = position;
int otherPos = otherBuffer.position;
byte thisByte, otherByte;
while (compareRemaining > 0) {
thisByte = get(thisPos);
otherByte = otherBuffer.get(otherPos);
if (thisByte != otherByte) {
return thisByte < otherByte ? -1 : 1;
}
thisPos++;
otherPos++;
compareRemaining--;
}
return remaining() - otherBuffer.remaining();
} | [
"public",
"int",
"compareTo",
"(",
"ByteBuffer",
"otherBuffer",
")",
"{",
"int",
"compareRemaining",
"=",
"(",
"remaining",
"(",
")",
"<",
"otherBuffer",
".",
"remaining",
"(",
")",
")",
"?",
"remaining",
"(",
")",
":",
"otherBuffer",
".",
"remaining",
"("... | Compares the remaining bytes of this buffer to another byte buffer's remaining bytes.
@param otherBuffer another byte buffer.
@return a negative value if this is less than {@code other}; 0 if this equals to {@code
other}; a positive value if this is greater than {@code other}.
@exception ClassCastException if {@code other} is not a byte buffer. | [
"Compares",
"the",
"remaining",
"bytes",
"of",
"this",
"buffer",
"to",
"another",
"byte",
"buffer",
"s",
"remaining",
"bytes",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/super/java/nio/ByteBuffer.java#L218-L235 | train |
playn/playn | html/src/playn/super/java/nio/ByteBuffer.java | ByteBuffer.get | public final ByteBuffer get (byte[] dest, int off, int len) {
int length = dest.length;
if (off < 0 || len < 0 || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferUnderflowException();
}
for (int i = 0; i < len; i++) {
dest[i + off] = get(position + i);
}
position += len;
return this;
} | java | public final ByteBuffer get (byte[] dest, int off, int len) {
int length = dest.length;
if (off < 0 || len < 0 || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferUnderflowException();
}
for (int i = 0; i < len; i++) {
dest[i + off] = get(position + i);
}
position += len;
return this;
} | [
"public",
"final",
"ByteBuffer",
"get",
"(",
"byte",
"[",
"]",
"dest",
",",
"int",
"off",
",",
"int",
"len",
")",
"{",
"int",
"length",
"=",
"dest",
".",
"length",
";",
"if",
"(",
"off",
"<",
"0",
"||",
"len",
"<",
"0",
"||",
"(",
"long",
")",
... | Reads bytes from the current position into the specified byte array, starting at the
specified offset, and increases the position by the number of bytes read.
@param dest the target byte array.
@param off the offset of the byte array, must not be negative and not greater than {@code
dest.length}.
@param len the number of bytes to read, must not be negative and not greater than {@code
dest.length - off}
@return this buffer.
@exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid.
@exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. | [
"Reads",
"bytes",
"from",
"the",
"current",
"position",
"into",
"the",
"specified",
"byte",
"array",
"starting",
"at",
"the",
"specified",
"offset",
"and",
"increases",
"the",
"position",
"by",
"the",
"number",
"of",
"bytes",
"read",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/super/java/nio/ByteBuffer.java#L316-L331 | train |
playn/playn | html/src/playn/super/java/nio/ByteBuffer.java | ByteBuffer.put | public ByteBuffer put (byte[] src, int off, int len) {
int length = src.length;
if (off < 0 || len < 0 || off + len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
for (int i = 0; i < len; i++) {
byteArray.set(i + position, src[off + i]);
}
position += len;
return this;
} | java | public ByteBuffer put (byte[] src, int off, int len) {
int length = src.length;
if (off < 0 || len < 0 || off + len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
for (int i = 0; i < len; i++) {
byteArray.set(i + position, src[off + i]);
}
position += len;
return this;
} | [
"public",
"ByteBuffer",
"put",
"(",
"byte",
"[",
"]",
"src",
",",
"int",
"off",
",",
"int",
"len",
")",
"{",
"int",
"length",
"=",
"src",
".",
"length",
";",
"if",
"(",
"off",
"<",
"0",
"||",
"len",
"<",
"0",
"||",
"off",
"+",
"len",
">",
"le... | Writes bytes in the given byte array, starting from the specified offset, to the current
position and increases the position by the number of bytes written.
@param src the source byte array.
@param off the offset of byte array, must not be negative and not greater than {@code
src.length}.
@param len the number of bytes to write, must not be negative and not greater than {@code
src.length - off}.
@return this buffer.
@exception BufferOverflowException if {@code remaining()} is less than {@code len}.
@exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid.
@exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. | [
"Writes",
"bytes",
"in",
"the",
"given",
"byte",
"array",
"starting",
"from",
"the",
"specified",
"offset",
"to",
"the",
"current",
"position",
"and",
"increases",
"the",
"position",
"by",
"the",
"number",
"of",
"bytes",
"written",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/super/java/nio/ByteBuffer.java#L629-L643 | train |
playn/playn | core/src/playn/core/Texture.java | Texture.close | @Override public void close () {
if (!disposed) {
disposed = true;
if (gfx.exec().isMainThread()) {
gfx.gl.glDeleteTexture(id);
} else {
gfx.exec().invokeNextFrame(new Runnable() {
public void run () { gfx.gl.glDeleteTexture(id); }
});
}
}
} | java | @Override public void close () {
if (!disposed) {
disposed = true;
if (gfx.exec().isMainThread()) {
gfx.gl.glDeleteTexture(id);
} else {
gfx.exec().invokeNextFrame(new Runnable() {
public void run () { gfx.gl.glDeleteTexture(id); }
});
}
}
} | [
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"!",
"disposed",
")",
"{",
"disposed",
"=",
"true",
";",
"if",
"(",
"gfx",
".",
"exec",
"(",
")",
".",
"isMainThread",
"(",
")",
")",
"{",
"gfx",
".",
"gl",
".",
"glDeleteTextu... | Deletes this texture's GPU resources and renders it unusable. | [
"Deletes",
"this",
"texture",
"s",
"GPU",
"resources",
"and",
"renders",
"it",
"unusable",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Texture.java#L240-L251 | train |
playn/playn | android/src/playn/android/AndroidGraphics.java | AndroidGraphics.onSurfaceChanged | public void onSurfaceChanged (int pixelWidth, int pixelHeight, int orient) {
viewportChanged(pixelWidth, pixelHeight);
screenSize.setSize(viewSize);
switch (orient) {
case Configuration.ORIENTATION_LANDSCAPE:
orientDetailM.update(OrientationDetail.LANDSCAPE_LEFT);
break;
case Configuration.ORIENTATION_PORTRAIT:
orientDetailM.update(OrientationDetail.PORTRAIT);
break;
default: // Configuration.ORIENTATION_UNDEFINED
orientDetailM.update(OrientationDetail.UNKNOWN);
break;
}
} | java | public void onSurfaceChanged (int pixelWidth, int pixelHeight, int orient) {
viewportChanged(pixelWidth, pixelHeight);
screenSize.setSize(viewSize);
switch (orient) {
case Configuration.ORIENTATION_LANDSCAPE:
orientDetailM.update(OrientationDetail.LANDSCAPE_LEFT);
break;
case Configuration.ORIENTATION_PORTRAIT:
orientDetailM.update(OrientationDetail.PORTRAIT);
break;
default: // Configuration.ORIENTATION_UNDEFINED
orientDetailM.update(OrientationDetail.UNKNOWN);
break;
}
} | [
"public",
"void",
"onSurfaceChanged",
"(",
"int",
"pixelWidth",
",",
"int",
"pixelHeight",
",",
"int",
"orient",
")",
"{",
"viewportChanged",
"(",
"pixelWidth",
",",
"pixelHeight",
")",
";",
"screenSize",
".",
"setSize",
"(",
"viewSize",
")",
";",
"switch",
... | Informs the graphics system that the surface into which it is rendering has changed size. The
supplied width and height are in pixels, not display units. | [
"Informs",
"the",
"graphics",
"system",
"that",
"the",
"surface",
"into",
"which",
"it",
"is",
"rendering",
"has",
"changed",
"size",
".",
"The",
"supplied",
"width",
"and",
"height",
"are",
"in",
"pixels",
"not",
"display",
"units",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/android/src/playn/android/AndroidGraphics.java#L134-L148 | train |
playn/playn | robovm/src/playn/robovm/RoboGraphics.java | RoboGraphics.viewDidInit | void viewDidInit(CGRect bounds) {
defaultFramebuffer = gl.glGetInteger(GL20.GL_FRAMEBUFFER_BINDING);
if (defaultFramebuffer == 0) throw new IllegalStateException(
"Failed to determine defaultFramebuffer");
boundsChanged(bounds);
} | java | void viewDidInit(CGRect bounds) {
defaultFramebuffer = gl.glGetInteger(GL20.GL_FRAMEBUFFER_BINDING);
if (defaultFramebuffer == 0) throw new IllegalStateException(
"Failed to determine defaultFramebuffer");
boundsChanged(bounds);
} | [
"void",
"viewDidInit",
"(",
"CGRect",
"bounds",
")",
"{",
"defaultFramebuffer",
"=",
"gl",
".",
"glGetInteger",
"(",
"GL20",
".",
"GL_FRAMEBUFFER_BINDING",
")",
";",
"if",
"(",
"defaultFramebuffer",
"==",
"0",
")",
"throw",
"new",
"IllegalStateException",
"(",
... | called when our view appears | [
"called",
"when",
"our",
"view",
"appears"
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/robovm/src/playn/robovm/RoboGraphics.java#L131-L136 | train |
playn/playn | core/src/playn/core/Input.java | Input.getText | public RFuture<String> getText (Keyboard.TextType textType, String label, String initialValue) {
return getText(textType, label, initialValue, "Ok", "Cancel");
} | java | public RFuture<String> getText (Keyboard.TextType textType, String label, String initialValue) {
return getText(textType, label, initialValue, "Ok", "Cancel");
} | [
"public",
"RFuture",
"<",
"String",
">",
"getText",
"(",
"Keyboard",
".",
"TextType",
"textType",
",",
"String",
"label",
",",
"String",
"initialValue",
")",
"{",
"return",
"getText",
"(",
"textType",
",",
"label",
",",
"initialValue",
",",
"\"Ok\"",
",",
... | Requests a line of text from the user. On platforms that have only a virtual keyboard, this
will display a text entry interface, obtain the line of text, and dismiss the text entry
interface when finished.
@param textType the expected type of text. On mobile devices this hint may be used to display a
keyboard customized to the particular type of text.
@param label a label to display over the text entry interface, may be null.
@param initialValue the initial value to display in the text input field, may be null.
@return a future which provides the text when it becomes available. If the user cancels the
text entry process, null is supplied. Otherwise the entered text is supplied. | [
"Requests",
"a",
"line",
"of",
"text",
"from",
"the",
"user",
".",
"On",
"platforms",
"that",
"have",
"only",
"a",
"virtual",
"keyboard",
"this",
"will",
"display",
"a",
"text",
"entry",
"interface",
"obtain",
"the",
"line",
"of",
"text",
"and",
"dismiss",... | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Input.java#L96-L98 | train |
playn/playn | core/src/playn/core/Input.java | Input.getText | public RFuture<String> getText (Keyboard.TextType textType, String label, String initialValue,
String ok, String cancel) {
return RFuture.failure(new Exception("getText not supported"));
} | java | public RFuture<String> getText (Keyboard.TextType textType, String label, String initialValue,
String ok, String cancel) {
return RFuture.failure(new Exception("getText not supported"));
} | [
"public",
"RFuture",
"<",
"String",
">",
"getText",
"(",
"Keyboard",
".",
"TextType",
"textType",
",",
"String",
"label",
",",
"String",
"initialValue",
",",
"String",
"ok",
",",
"String",
"cancel",
")",
"{",
"return",
"RFuture",
".",
"failure",
"(",
"new"... | Requests a line of text from the user. On platforms that have only a virtual keyboard, this
will display a text entry interface, obtain the line of text, and dismiss the text entry
interface when finished. Note that HTML5 and some Java backends do not support customization
of the OK and Cancel labels. Thus those platforms will ignore the supplied labels and use
their mandatory labels.
@param textType the expected type of text. On mobile devices this hint may be used to display a
keyboard customized to the particular type of text.
@param label a label to display over the text entry interface, may be null.
@param initialValue the initial value to display in the text input field, may be null.
@param ok the text of the button which will deliver a {@code true} result and be placed in
"OK" position for the platform.
@param cancel the text of the button that will deliver a {@code false} result and be placed in
"Cancel" position.
@return a future which provides the text when it becomes available. If the user cancels the
text entry process, null is supplied. Otherwise the entered text is supplied. | [
"Requests",
"a",
"line",
"of",
"text",
"from",
"the",
"user",
".",
"On",
"platforms",
"that",
"have",
"only",
"a",
"virtual",
"keyboard",
"this",
"will",
"display",
"a",
"text",
"entry",
"interface",
"obtain",
"the",
"line",
"of",
"text",
"and",
"dismiss",... | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Input.java#L119-L122 | train |
playn/playn | core/src/playn/core/Input.java | Input.sysDialog | public RFuture<Boolean> sysDialog (String title, String text, String ok, String cancel) {
return RFuture.failure(new Exception("sysDialog not supported"));
} | java | public RFuture<Boolean> sysDialog (String title, String text, String ok, String cancel) {
return RFuture.failure(new Exception("sysDialog not supported"));
} | [
"public",
"RFuture",
"<",
"Boolean",
">",
"sysDialog",
"(",
"String",
"title",
",",
"String",
"text",
",",
"String",
"ok",
",",
"String",
"cancel",
")",
"{",
"return",
"RFuture",
".",
"failure",
"(",
"new",
"Exception",
"(",
"\"sysDialog not supported\"",
")... | Displays a system dialog with the specified title and text, an OK button and optionally a
Cancel button.
@param title the title for the dialog window. Note: some platforms (mainly mobile) do not
display the title, so be sure your dialog makes sense if only {@code text} is showing.
@param text the text of the dialog. The text will be wrapped by the underlying platform, but
PlayN will do its utmost to ensure that newlines are honored by the platform in question so
that hard line breaks and blank lines are reproduced correctly.
@param ok the text of the button which will deliver a {@code true} result and be placed in
"OK" position for the platform. Note: the HTML platform does not support customizing this
label, so on that platform the label will be "OK". Yay for HTML5.
@param cancel the text of the button that will deliver a {@code false} result and be placed in
"Cancel" position. If {@code null} is supplied, the dialog will only have an OK button. Note:
the HTML platform does not support customizing this label, so on that platform a non-null
cancel string will result in the button reading "Cancel". Yay for HTML5.
@return a future which delivers {@code true} or {@code false} when the user clicks the OK or
cancel buttons respectively. If some unexpected error occurs displaying the dialog (unlikley),
it will be reported by failing the future. | [
"Displays",
"a",
"system",
"dialog",
"with",
"the",
"specified",
"title",
"and",
"text",
"an",
"OK",
"button",
"and",
"optionally",
"a",
"Cancel",
"button",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Input.java#L145-L147 | train |
playn/playn | scene/src/playn/scene/LayerUtil.java | LayerUtil.layerToScreen | public static Point layerToScreen(Layer layer, float x, float y) {
Point into = new Point(x, y);
return layerToScreen(layer, into, into);
} | java | public static Point layerToScreen(Layer layer, float x, float y) {
Point into = new Point(x, y);
return layerToScreen(layer, into, into);
} | [
"public",
"static",
"Point",
"layerToScreen",
"(",
"Layer",
"layer",
",",
"float",
"x",
",",
"float",
"y",
")",
"{",
"Point",
"into",
"=",
"new",
"Point",
"(",
"x",
",",
"y",
")",
";",
"return",
"layerToScreen",
"(",
"layer",
",",
"into",
",",
"into"... | Converts the supplied point from coordinates relative to the specified
layer to screen coordinates. | [
"Converts",
"the",
"supplied",
"point",
"from",
"coordinates",
"relative",
"to",
"the",
"specified",
"layer",
"to",
"screen",
"coordinates",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/LayerUtil.java#L44-L47 | train |
playn/playn | scene/src/playn/scene/LayerUtil.java | LayerUtil.layerToParent | public static Point layerToParent(Layer layer, Layer parent, float x, float y) {
Point into = new Point(x, y);
return layerToParent(layer, parent, into, into);
} | java | public static Point layerToParent(Layer layer, Layer parent, float x, float y) {
Point into = new Point(x, y);
return layerToParent(layer, parent, into, into);
} | [
"public",
"static",
"Point",
"layerToParent",
"(",
"Layer",
"layer",
",",
"Layer",
"parent",
",",
"float",
"x",
",",
"float",
"y",
")",
"{",
"Point",
"into",
"=",
"new",
"Point",
"(",
"x",
",",
"y",
")",
";",
"return",
"layerToParent",
"(",
"layer",
... | Converts the supplied point from coordinates relative to the specified
child layer to coordinates relative to the specified parent layer. | [
"Converts",
"the",
"supplied",
"point",
"from",
"coordinates",
"relative",
"to",
"the",
"specified",
"child",
"layer",
"to",
"coordinates",
"relative",
"to",
"the",
"specified",
"parent",
"layer",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/LayerUtil.java#L74-L77 | train |
playn/playn | scene/src/playn/scene/LayerUtil.java | LayerUtil.screenToLayer | public static Point screenToLayer(Layer layer, float x, float y) {
Point into = new Point(x, y);
return screenToLayer(layer, into, into);
} | java | public static Point screenToLayer(Layer layer, float x, float y) {
Point into = new Point(x, y);
return screenToLayer(layer, into, into);
} | [
"public",
"static",
"Point",
"screenToLayer",
"(",
"Layer",
"layer",
",",
"float",
"x",
",",
"float",
"y",
")",
"{",
"Point",
"into",
"=",
"new",
"Point",
"(",
"x",
",",
"y",
")",
";",
"return",
"screenToLayer",
"(",
"layer",
",",
"into",
",",
"into"... | Converts the supplied point from screen coordinates to coordinates
relative to the specified layer. | [
"Converts",
"the",
"supplied",
"point",
"from",
"screen",
"coordinates",
"to",
"coordinates",
"relative",
"to",
"the",
"specified",
"layer",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/LayerUtil.java#L94-L97 | train |
playn/playn | scene/src/playn/scene/LayerUtil.java | LayerUtil.layerUnderPoint | public static Layer layerUnderPoint (Layer root, float x, float y) {
Point p = new Point(x, y);
root.transform().inverseTransform(p, p);
p.x += root.originX();
p.y += root.originY();
return layerUnderPoint(root, p);
} | java | public static Layer layerUnderPoint (Layer root, float x, float y) {
Point p = new Point(x, y);
root.transform().inverseTransform(p, p);
p.x += root.originX();
p.y += root.originY();
return layerUnderPoint(root, p);
} | [
"public",
"static",
"Layer",
"layerUnderPoint",
"(",
"Layer",
"root",
",",
"float",
"x",
",",
"float",
"y",
")",
"{",
"Point",
"p",
"=",
"new",
"Point",
"(",
"x",
",",
"y",
")",
";",
"root",
".",
"transform",
"(",
")",
".",
"inverseTransform",
"(",
... | Gets the layer underneath the given screen coordinates, ignoring hit testers. This is
useful for inspecting the scene graph for debugging purposes, and is not intended for use
is shipped code. The layer returned is the one that has a size and is the deepest within
the graph and contains the coordinate. | [
"Gets",
"the",
"layer",
"underneath",
"the",
"given",
"screen",
"coordinates",
"ignoring",
"hit",
"testers",
".",
"This",
"is",
"useful",
"for",
"inspecting",
"the",
"scene",
"graph",
"for",
"debugging",
"purposes",
"and",
"is",
"not",
"intended",
"for",
"use"... | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/LayerUtil.java#L159-L165 | train |
playn/playn | scene/src/playn/scene/LayerUtil.java | LayerUtil.indexInParent | public static int indexInParent (Layer layer) {
GroupLayer parent = layer.parent();
if (parent == null) return -1;
for (int ii = parent.children()-1; ii >= 0; ii--) {
if (parent.childAt(ii) == layer) return ii;
}
throw new AssertionError();
} | java | public static int indexInParent (Layer layer) {
GroupLayer parent = layer.parent();
if (parent == null) return -1;
for (int ii = parent.children()-1; ii >= 0; ii--) {
if (parent.childAt(ii) == layer) return ii;
}
throw new AssertionError();
} | [
"public",
"static",
"int",
"indexInParent",
"(",
"Layer",
"layer",
")",
"{",
"GroupLayer",
"parent",
"=",
"layer",
".",
"parent",
"(",
")",
";",
"if",
"(",
"parent",
"==",
"null",
")",
"return",
"-",
"1",
";",
"for",
"(",
"int",
"ii",
"=",
"parent",
... | Returns the index of the given layer within its parent, or -1 if the parent is null. | [
"Returns",
"the",
"index",
"of",
"the",
"given",
"layer",
"within",
"its",
"parent",
"or",
"-",
"1",
"if",
"the",
"parent",
"is",
"null",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/LayerUtil.java#L170-L177 | train |
playn/playn | core/src/playn/core/RenderTarget.java | RenderTarget.bind | public void bind () {
gfx.gl.glBindFramebuffer(GL_FRAMEBUFFER, id());
gfx.gl.glViewport(0, 0, width(), height());
} | java | public void bind () {
gfx.gl.glBindFramebuffer(GL_FRAMEBUFFER, id());
gfx.gl.glViewport(0, 0, width(), height());
} | [
"public",
"void",
"bind",
"(",
")",
"{",
"gfx",
".",
"gl",
".",
"glBindFramebuffer",
"(",
"GL_FRAMEBUFFER",
",",
"id",
"(",
")",
")",
";",
"gfx",
".",
"gl",
".",
"glViewport",
"(",
"0",
",",
"0",
",",
"width",
"(",
")",
",",
"height",
"(",
")",
... | Binds the framebuffer. | [
"Binds",
"the",
"framebuffer",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/RenderTarget.java#L70-L73 | train |
playn/playn | core/src/playn/core/GLProgram.java | GLProgram.close | @Override public void close () {
gl.glDeleteShader(vertexShader);
gl.glDeleteShader(fragmentShader);
gl.glDeleteProgram(id);
} | java | @Override public void close () {
gl.glDeleteShader(vertexShader);
gl.glDeleteShader(fragmentShader);
gl.glDeleteProgram(id);
} | [
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"gl",
".",
"glDeleteShader",
"(",
"vertexShader",
")",
";",
"gl",
".",
"glDeleteShader",
"(",
"fragmentShader",
")",
";",
"gl",
".",
"glDeleteProgram",
"(",
"id",
")",
";",
"}"
] | Frees this program and associated compiled shaders.
The program must not be used after closure. | [
"Frees",
"this",
"program",
"and",
"associated",
"compiled",
"shaders",
".",
"The",
"program",
"must",
"not",
"be",
"used",
"after",
"closure",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/GLProgram.java#L99-L103 | train |
playn/playn | core/src/playn/core/json/JsonWriterBase.java | JsonWriterBase.emitStringValue | private void emitStringValue(String s) {
raw('"');
char b = 0, c = 0;
for (int i = 0; i < s.length(); i++) {
b = c;
c = s.charAt(i);
switch (c) {
case '\\':
case '"':
raw('\\');
raw(c);
break;
case '/':
// Special case to ensure that </script> doesn't appear in JSON
// output
if (b == '<')
raw('\\');
raw(c);
break;
case '\b':
raw("\\b");
break;
case '\t':
raw("\\t");
break;
case '\n':
raw("\\n");
break;
case '\f':
raw("\\f");
break;
case '\r':
raw("\\r");
break;
default:
if (shouldBeEscaped(c)) {
String t = "000" + Integer.toHexString(c);
raw("\\u" + t.substring(t.length() - "0000".length()));
} else {
raw(c);
}
}
}
raw('"');
} | java | private void emitStringValue(String s) {
raw('"');
char b = 0, c = 0;
for (int i = 0; i < s.length(); i++) {
b = c;
c = s.charAt(i);
switch (c) {
case '\\':
case '"':
raw('\\');
raw(c);
break;
case '/':
// Special case to ensure that </script> doesn't appear in JSON
// output
if (b == '<')
raw('\\');
raw(c);
break;
case '\b':
raw("\\b");
break;
case '\t':
raw("\\t");
break;
case '\n':
raw("\\n");
break;
case '\f':
raw("\\f");
break;
case '\r':
raw("\\r");
break;
default:
if (shouldBeEscaped(c)) {
String t = "000" + Integer.toHexString(c);
raw("\\u" + t.substring(t.length() - "0000".length()));
} else {
raw(c);
}
}
}
raw('"');
} | [
"private",
"void",
"emitStringValue",
"(",
"String",
"s",
")",
"{",
"raw",
"(",
"'",
"'",
")",
";",
"char",
"b",
"=",
"0",
",",
"c",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"s",
".",
"length",
"(",
")",
";",
"i",
"... | Emits a quoted string value, escaping characters that are required to be escaped. | [
"Emits",
"a",
"quoted",
"string",
"value",
"escaping",
"characters",
"that",
"are",
"required",
"to",
"be",
"escaped",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/json/JsonWriterBase.java#L399-L445 | train |
playn/playn | java-base/src/playn/java/JavaGraphics.java | JavaGraphics.aaFontContext | FontRenderContext aaFontContext() {
if (aaFontContext == null) {
// set up the dummy font contexts
Graphics2D aaGfx = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics();
aaGfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
aaFontContext = aaGfx.getFontRenderContext();
}
return aaFontContext;
} | java | FontRenderContext aaFontContext() {
if (aaFontContext == null) {
// set up the dummy font contexts
Graphics2D aaGfx = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics();
aaGfx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
aaFontContext = aaGfx.getFontRenderContext();
}
return aaFontContext;
} | [
"FontRenderContext",
"aaFontContext",
"(",
")",
"{",
"if",
"(",
"aaFontContext",
"==",
"null",
")",
"{",
"// set up the dummy font contexts",
"Graphics2D",
"aaGfx",
"=",
"new",
"BufferedImage",
"(",
"1",
",",
"1",
",",
"BufferedImage",
".",
"TYPE_INT_ARGB",
")",
... | these are initialized lazily to avoid doing any AWT stuff during startup | [
"these",
"are",
"initialized",
"lazily",
"to",
"avoid",
"doing",
"any",
"AWT",
"stuff",
"during",
"startup"
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/java-base/src/playn/java/JavaGraphics.java#L47-L55 | train |
playn/playn | html/src/playn/super/java/nio/DoubleBuffer.java | DoubleBuffer.compareTo | public int compareTo (DoubleBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ?
remaining() : otherBuffer.remaining();
int thisPos = position;
int otherPos = otherBuffer.position;
// BEGIN android-changed
double thisDouble, otherDouble;
while (compareRemaining > 0) {
thisDouble = get(thisPos);
otherDouble = otherBuffer.get(otherPos);
// checks for double and NaN inequality
if ((thisDouble != otherDouble) &&
((thisDouble == thisDouble) || (otherDouble == otherDouble))) {
return thisDouble < otherDouble ? -1 : 1;
}
thisPos++;
otherPos++;
compareRemaining--;
}
// END android-changed
return remaining() - otherBuffer.remaining();
} | java | public int compareTo (DoubleBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ?
remaining() : otherBuffer.remaining();
int thisPos = position;
int otherPos = otherBuffer.position;
// BEGIN android-changed
double thisDouble, otherDouble;
while (compareRemaining > 0) {
thisDouble = get(thisPos);
otherDouble = otherBuffer.get(otherPos);
// checks for double and NaN inequality
if ((thisDouble != otherDouble) &&
((thisDouble == thisDouble) || (otherDouble == otherDouble))) {
return thisDouble < otherDouble ? -1 : 1;
}
thisPos++;
otherPos++;
compareRemaining--;
}
// END android-changed
return remaining() - otherBuffer.remaining();
} | [
"public",
"int",
"compareTo",
"(",
"DoubleBuffer",
"otherBuffer",
")",
"{",
"int",
"compareRemaining",
"=",
"(",
"remaining",
"(",
")",
"<",
"otherBuffer",
".",
"remaining",
"(",
")",
")",
"?",
"remaining",
"(",
")",
":",
"otherBuffer",
".",
"remaining",
"... | Compare the remaining doubles of this buffer to another double buffer's remaining doubles.
@param otherBuffer another double buffer.
@return a negative value if this is less than {@code other}; 0 if this equals to {@code
other}; a positive value if this is greater than {@code other}.
@exception ClassCastException if {@code other} is not a double buffer. | [
"Compare",
"the",
"remaining",
"doubles",
"of",
"this",
"buffer",
"to",
"another",
"double",
"buffer",
"s",
"remaining",
"doubles",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/super/java/nio/DoubleBuffer.java#L105-L126 | train |
playn/playn | html/src/playn/super/java/nio/DoubleBuffer.java | DoubleBuffer.get | public DoubleBuffer get (double[] dest, int off, int len) {
int length = dest.length;
if (off < 0 || len < 0 || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferUnderflowException();
}
for (int i = off; i < off + len; i++) {
dest[i] = get();
}
return this;
} | java | public DoubleBuffer get (double[] dest, int off, int len) {
int length = dest.length;
if (off < 0 || len < 0 || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferUnderflowException();
}
for (int i = off; i < off + len; i++) {
dest[i] = get();
}
return this;
} | [
"public",
"DoubleBuffer",
"get",
"(",
"double",
"[",
"]",
"dest",
",",
"int",
"off",
",",
"int",
"len",
")",
"{",
"int",
"length",
"=",
"dest",
".",
"length",
";",
"if",
"(",
"off",
"<",
"0",
"||",
"len",
"<",
"0",
"||",
"(",
"long",
")",
"off"... | Reads doubles from the current position into the specified double array, starting from the
specified offset, and increases the position by the number of doubles read.
@param dest the target double array.
@param off the offset of the double array, must not be negative and not greater than {@code
dest.length}.
@param len the number of doubles to read, must be no less than zero and not greater than
{@code dest.length - off}.
@return this buffer.
@exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid.
@exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. | [
"Reads",
"doubles",
"from",
"the",
"current",
"position",
"into",
"the",
"specified",
"double",
"array",
"starting",
"from",
"the",
"specified",
"offset",
"and",
"increases",
"the",
"position",
"by",
"the",
"number",
"of",
"doubles",
"read",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/super/java/nio/DoubleBuffer.java#L199-L212 | train |
playn/playn | html/src/playn/super/java/nio/DoubleBuffer.java | DoubleBuffer.put | public DoubleBuffer put (double[] src, int off, int len) {
int length = src.length;
if (off < 0 || len < 0 || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
for (int i = off; i < off + len; i++) {
put(src[i]);
}
return this;
} | java | public DoubleBuffer put (double[] src, int off, int len) {
int length = src.length;
if (off < 0 || len < 0 || (long)off + (long)len > length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
for (int i = off; i < off + len; i++) {
put(src[i]);
}
return this;
} | [
"public",
"DoubleBuffer",
"put",
"(",
"double",
"[",
"]",
"src",
",",
"int",
"off",
",",
"int",
"len",
")",
"{",
"int",
"length",
"=",
"src",
".",
"length",
";",
"if",
"(",
"off",
"<",
"0",
"||",
"len",
"<",
"0",
"||",
"(",
"long",
")",
"off",
... | Writes doubles from the given double array, starting from the specified offset, to the
current position and increases the position by the number of doubles written.
@param src the source double array.
@param off the offset of double array, must not be negative and not greater than {@code
src.length}.
@param len the number of doubles to write, must be no less than zero and not greater than
{@code src.length - off}.
@return this buffer.
@exception BufferOverflowException if {@code remaining()} is less than {@code len}.
@exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid.
@exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. | [
"Writes",
"doubles",
"from",
"the",
"given",
"double",
"array",
"starting",
"from",
"the",
"specified",
"offset",
"to",
"the",
"current",
"position",
"and",
"increases",
"the",
"position",
"by",
"the",
"number",
"of",
"doubles",
"written",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/super/java/nio/DoubleBuffer.java#L316-L329 | train |
playn/playn | core/src/playn/core/SoundImpl.java | SoundImpl.succeed | public synchronized void succeed (I impl) {
this.impl = impl;
setVolumeImpl(volume);
setLoopingImpl(looping);
if (playing) playImpl();
((RPromise<Sound>)state).succeed(this);
} | java | public synchronized void succeed (I impl) {
this.impl = impl;
setVolumeImpl(volume);
setLoopingImpl(looping);
if (playing) playImpl();
((RPromise<Sound>)state).succeed(this);
} | [
"public",
"synchronized",
"void",
"succeed",
"(",
"I",
"impl",
")",
"{",
"this",
".",
"impl",
"=",
"impl",
";",
"setVolumeImpl",
"(",
"volume",
")",
";",
"setLoopingImpl",
"(",
"looping",
")",
";",
"if",
"(",
"playing",
")",
"playImpl",
"(",
")",
";",
... | Configures this sound with its platform implementation.
This may be called from any thread. | [
"Configures",
"this",
"sound",
"with",
"its",
"platform",
"implementation",
".",
"This",
"may",
"be",
"called",
"from",
"any",
"thread",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/SoundImpl.java#L36-L42 | train |
playn/playn | java-lwjgl/src/playn/java/GLFWInput.java | GLFWInput.toModifierFlags | private int toModifierFlags (int mods) {
return modifierFlags((mods & GLFW_MOD_ALT) != 0,
(mods & GLFW_MOD_CONTROL) != 0,
(mods & GLFW_MOD_SUPER) != 0,
(mods & GLFW_MOD_SHIFT) != 0);
} | java | private int toModifierFlags (int mods) {
return modifierFlags((mods & GLFW_MOD_ALT) != 0,
(mods & GLFW_MOD_CONTROL) != 0,
(mods & GLFW_MOD_SUPER) != 0,
(mods & GLFW_MOD_SHIFT) != 0);
} | [
"private",
"int",
"toModifierFlags",
"(",
"int",
"mods",
")",
"{",
"return",
"modifierFlags",
"(",
"(",
"mods",
"&",
"GLFW_MOD_ALT",
")",
"!=",
"0",
",",
"(",
"mods",
"&",
"GLFW_MOD_CONTROL",
")",
"!=",
"0",
",",
"(",
"mods",
"&",
"GLFW_MOD_SUPER",
")",
... | Converts GLFW modifier key flags into PlayN modifier key flags. | [
"Converts",
"GLFW",
"modifier",
"key",
"flags",
"into",
"PlayN",
"modifier",
"key",
"flags",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/java-lwjgl/src/playn/java/GLFWInput.java#L174-L179 | train |
playn/playn | core/src/playn/core/Exec.java | Exec.deferredPromise | public <T> RPromise<T> deferredPromise () {
return new RPromise<T>() {
@Override public void succeed (final T value) {
invokeLater(new Runnable() {
public void run () { superSucceed(value); }
});
}
@Override public void fail (final Throwable cause) {
invokeLater(new Runnable() {
public void run () { superFail(cause); }
});
}
private void superSucceed (T value) { super.succeed(value); }
private void superFail (Throwable cause) { super.fail(cause); }
};
} | java | public <T> RPromise<T> deferredPromise () {
return new RPromise<T>() {
@Override public void succeed (final T value) {
invokeLater(new Runnable() {
public void run () { superSucceed(value); }
});
}
@Override public void fail (final Throwable cause) {
invokeLater(new Runnable() {
public void run () { superFail(cause); }
});
}
private void superSucceed (T value) { super.succeed(value); }
private void superFail (Throwable cause) { super.fail(cause); }
};
} | [
"public",
"<",
"T",
">",
"RPromise",
"<",
"T",
">",
"deferredPromise",
"(",
")",
"{",
"return",
"new",
"RPromise",
"<",
"T",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"succeed",
"(",
"final",
"T",
"value",
")",
"{",
"invokeLater",
"(",
... | Creates a promise which defers notification of success or failure to the game thread,
regardless of what thread on which it is completed. Note that even if it is completed on the
game thread, it will still defer completion until the next frame. | [
"Creates",
"a",
"promise",
"which",
"defers",
"notification",
"of",
"success",
"or",
"failure",
"to",
"the",
"game",
"thread",
"regardless",
"of",
"what",
"thread",
"on",
"which",
"it",
"is",
"completed",
".",
"Note",
"that",
"even",
"if",
"it",
"is",
"com... | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Exec.java#L100-L115 | train |
playn/playn | core/src/playn/core/TriangleBatch.java | TriangleBatch.addTris | public void addTris (Texture tex, int tint, AffineTransform xf,
float[] xys, int xysOffset, int xysLen, float tw, float th,
int[] indices, int indicesOffset, int indicesLen, int indexBase) {
setTexture(tex);
prepare(tint, xf);
addTris(xys, xysOffset, xysLen, tw, th, indices, indicesOffset, indicesLen, indexBase);
} | java | public void addTris (Texture tex, int tint, AffineTransform xf,
float[] xys, int xysOffset, int xysLen, float tw, float th,
int[] indices, int indicesOffset, int indicesLen, int indexBase) {
setTexture(tex);
prepare(tint, xf);
addTris(xys, xysOffset, xysLen, tw, th, indices, indicesOffset, indicesLen, indexBase);
} | [
"public",
"void",
"addTris",
"(",
"Texture",
"tex",
",",
"int",
"tint",
",",
"AffineTransform",
"xf",
",",
"float",
"[",
"]",
"xys",
",",
"int",
"xysOffset",
",",
"int",
"xysLen",
",",
"float",
"tw",
",",
"float",
"th",
",",
"int",
"[",
"]",
"indices... | Adds a collection of textured triangles to the current render operation.
@param xys a list of x/y coordinates as: {@code [x1, y1, x2, y2, ...]}.
@param xysOffset the offset of the coordinates array, must not be negative and no greater than
{@code xys.length}. Note: this is an absolute offset; since {@code xys} contains pairs of
values, this will be some multiple of two.
@param xysLen the number of coordinates to read, must be no less than zero and no greater than
{@code xys.length - xysOffset}. Note: this is an absolute length; since {@code xys} contains
pairs of values, this will be some multiple of two.
@param tw the width of the texture for which we will auto-generate texture coordinates.
@param th the height of the texture for which we will auto-generate texture coordinates.
@param indices the index of the triangle vertices in the {@code xys} array. Because this
method renders a slice of {@code xys}, one must also specify {@code indexBase} which tells us
how to interpret indices. The index into {@code xys} will be computed as:
{@code 2*(indices[ii] - indexBase)}, so if your indices reference vertices relative to the
whole array you should pass {@code xysOffset/2} for {@code indexBase}, but if your indices
reference vertices relative to <em>the slice</em> then you should pass zero.
@param indicesOffset the offset of the indices array, must not be negative and no greater than
{@code indices.length}.
@param indicesLen the number of indices to read, must be no less than zero and no greater than
{@code indices.length - indicesOffset}.
@param indexBase the basis for interpreting {@code indices}. See the docs for {@code indices}
for details. | [
"Adds",
"a",
"collection",
"of",
"textured",
"triangles",
"to",
"the",
"current",
"render",
"operation",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/TriangleBatch.java#L194-L200 | train |
playn/playn | html/src/playn/html/HtmlFontMetrics.java | HtmlFontMetrics.adjustWidth | public float adjustWidth(float width) {
// Canvas.measureText does not account for the extra width consumed by italic characters, so we
// fudge in a fraction of an em and hope the font isn't too slanted
switch (font.style) {
case ITALIC: return width + emwidth/8;
case BOLD_ITALIC: return width + emwidth/6;
default: return width; // nada
}
} | java | public float adjustWidth(float width) {
// Canvas.measureText does not account for the extra width consumed by italic characters, so we
// fudge in a fraction of an em and hope the font isn't too slanted
switch (font.style) {
case ITALIC: return width + emwidth/8;
case BOLD_ITALIC: return width + emwidth/6;
default: return width; // nada
}
} | [
"public",
"float",
"adjustWidth",
"(",
"float",
"width",
")",
"{",
"// Canvas.measureText does not account for the extra width consumed by italic characters, so we",
"// fudge in a fraction of an em and hope the font isn't too slanted",
"switch",
"(",
"font",
".",
"style",
")",
"{",
... | Adjusts a measured width to account for italic and bold italic text. We have to handle this
hackily because there's no way to measure exact text extent in HTML5. | [
"Adjusts",
"a",
"measured",
"width",
"to",
"account",
"for",
"italic",
"and",
"bold",
"italic",
"text",
".",
"We",
"have",
"to",
"handle",
"this",
"hackily",
"because",
"there",
"s",
"no",
"way",
"to",
"measure",
"exact",
"text",
"extent",
"in",
"HTML5",
... | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/html/HtmlFontMetrics.java#L65-L73 | train |
playn/playn | html/src/playn/rebind/AutoClientBundleGenerator.java | AutoClientBundleGenerator.getWarDirectory | private File getWarDirectory(TreeLogger logger) throws UnableToCompleteException {
File currentDirectory = new File(".");
try {
String canonicalPath = currentDirectory.getCanonicalPath();
logger.log(TreeLogger.INFO, "Current directory in which this generator is executing: "
+ canonicalPath);
if (canonicalPath.endsWith("war")) {
return currentDirectory;
} else {
return new File("war");
}
} catch (IOException e) {
logger.log(TreeLogger.ERROR, "Failed to get canonical path", e);
throw new UnableToCompleteException();
}
} | java | private File getWarDirectory(TreeLogger logger) throws UnableToCompleteException {
File currentDirectory = new File(".");
try {
String canonicalPath = currentDirectory.getCanonicalPath();
logger.log(TreeLogger.INFO, "Current directory in which this generator is executing: "
+ canonicalPath);
if (canonicalPath.endsWith("war")) {
return currentDirectory;
} else {
return new File("war");
}
} catch (IOException e) {
logger.log(TreeLogger.ERROR, "Failed to get canonical path", e);
throw new UnableToCompleteException();
}
} | [
"private",
"File",
"getWarDirectory",
"(",
"TreeLogger",
"logger",
")",
"throws",
"UnableToCompleteException",
"{",
"File",
"currentDirectory",
"=",
"new",
"File",
"(",
"\".\"",
")",
";",
"try",
"{",
"String",
"canonicalPath",
"=",
"currentDirectory",
".",
"getCan... | When invoking the GWT compiler from GPE, the working directory is the Eclipse project
directory. However, when launching a GPE project, the working directory is the project 'war'
directory. This methods returns the war directory in either case in a fairly naive and
non-robust manner. | [
"When",
"invoking",
"the",
"GWT",
"compiler",
"from",
"GPE",
"the",
"working",
"directory",
"is",
"the",
"Eclipse",
"project",
"directory",
".",
"However",
"when",
"launching",
"a",
"GPE",
"project",
"the",
"working",
"directory",
"is",
"the",
"project",
"war"... | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/rebind/AutoClientBundleGenerator.java#L291-L306 | train |
playn/playn | scene/src/playn/scene/SceneGame.java | SceneGame.paintScene | protected void paintScene () {
viewSurf.saveTx();
viewSurf.begin();
viewSurf.clear(cred, cgreen, cblue, calpha);
try {
rootLayer.paint(viewSurf);
} finally {
viewSurf.end();
viewSurf.restoreTx();
}
} | java | protected void paintScene () {
viewSurf.saveTx();
viewSurf.begin();
viewSurf.clear(cred, cgreen, cblue, calpha);
try {
rootLayer.paint(viewSurf);
} finally {
viewSurf.end();
viewSurf.restoreTx();
}
} | [
"protected",
"void",
"paintScene",
"(",
")",
"{",
"viewSurf",
".",
"saveTx",
"(",
")",
";",
"viewSurf",
".",
"begin",
"(",
")",
";",
"viewSurf",
".",
"clear",
"(",
"cred",
",",
"cgreen",
",",
"cblue",
",",
"calpha",
")",
";",
"try",
"{",
"rootLayer",... | Renders the main scene graph into the OpenGL frame buffer. | [
"Renders",
"the",
"main",
"scene",
"graph",
"into",
"the",
"OpenGL",
"frame",
"buffer",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/scene/src/playn/scene/SceneGame.java#L68-L78 | train |
playn/playn | java-base/src/playn/java/JavaAssets.java | JavaAssets.requireResource | protected Resource requireResource(String path) throws IOException {
URL url = getClass().getClassLoader().getResource(pathPrefix + path);
if (url != null) {
return url.getProtocol().equals("file") ?
new FileResource(new File(URLDecoder.decode(url.getPath(), "UTF-8"))) :
new URLResource(url);
}
for (File dir : directories) {
File f = new File(dir, path).getCanonicalFile();
if (f.exists()) {
return new FileResource(f);
}
}
throw new FileNotFoundException(path);
} | java | protected Resource requireResource(String path) throws IOException {
URL url = getClass().getClassLoader().getResource(pathPrefix + path);
if (url != null) {
return url.getProtocol().equals("file") ?
new FileResource(new File(URLDecoder.decode(url.getPath(), "UTF-8"))) :
new URLResource(url);
}
for (File dir : directories) {
File f = new File(dir, path).getCanonicalFile();
if (f.exists()) {
return new FileResource(f);
}
}
throw new FileNotFoundException(path);
} | [
"protected",
"Resource",
"requireResource",
"(",
"String",
"path",
")",
"throws",
"IOException",
"{",
"URL",
"url",
"=",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"pathPrefix",
"+",
"path",
")",
";",
"if",
"(",
"url",
... | Attempts to locate the resource at the given path, and returns a wrapper which allows its data
to be efficiently read.
<p>First, the path prefix is prepended (see {@link #setPathPrefix(String)}) and the the class
loader checked. If not found, then the extra directories, if any, are checked, in order. If
the file is not found in any of the extra directories either, then an exception is thrown. | [
"Attempts",
"to",
"locate",
"the",
"resource",
"at",
"the",
"given",
"path",
"and",
"returns",
"a",
"wrapper",
"which",
"allows",
"its",
"data",
"to",
"be",
"efficiently",
"read",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/java-base/src/playn/java/JavaAssets.java#L174-L188 | train |
playn/playn | html/src/playn/html/HtmlGL20.java | HtmlGL20.prepareDraw | protected void prepareDraw() {
VertexAttribArrayState previousNio = null;
int previousElementSize = 0;
if (useNioBuffer == 0 && enabledArrays == previouslyEnabledArrays) {
return;
}
for(int i = 0; i < VERTEX_ATTRIB_ARRAY_COUNT; i++) {
int mask = 1 << i;
int enabled = enabledArrays & mask;
if (enabled != (previouslyEnabledArrays & mask)) {
if (enabled != 0) {
gl.enableVertexAttribArray(i);
} else {
gl.disableVertexAttribArray(i);
}
}
if (enabled != 0 && (useNioBuffer & mask) != 0) {
VertexAttribArrayState data = vertexAttribArrayState[i];
if (previousNio != null && previousNio.nioBuffer == data.nioBuffer &&
previousNio.nioBufferLimit >= data.nioBufferLimit) {
if (boundArrayBuffer != previousNio.webGlBuffer) {
gl.bindBuffer(ARRAY_BUFFER, previousNio.webGlBuffer);
boundArrayBuffer = data.webGlBuffer;
}
gl.vertexAttribPointer(i, data.size, data.type, data.normalize, data.stride,
data.nioBufferPosition * previousElementSize);
} else {
if (boundArrayBuffer != data.webGlBuffer) {
gl.bindBuffer(ARRAY_BUFFER, data.webGlBuffer);
boundArrayBuffer = data.webGlBuffer;
}
int elementSize = getElementSize(data.nioBuffer);
int savePosition = data.nioBuffer.position();
if (data.nioBufferPosition * elementSize < data.stride) {
data.nioBuffer.position(0);
gl.bufferData(ARRAY_BUFFER, getTypedArray(data.nioBuffer, data.type, data.nioBufferLimit *
elementSize), STREAM_DRAW);
gl.vertexAttribPointer(i, data.size, data.type, data.normalize, data.stride,
data.nioBufferPosition * elementSize);
previousNio = data;
previousElementSize = elementSize;
} else {
data.nioBuffer.position(data.nioBufferPosition);
gl.bufferData(ARRAY_BUFFER, getTypedArray(data.nioBuffer, data.type,
(data.nioBufferLimit - data.nioBufferPosition) *
elementSize), STREAM_DRAW);
gl.vertexAttribPointer(i, data.size, data.type, data.normalize, data.stride, 0);
}
data.nioBuffer.position(savePosition);
}
}
}
previouslyEnabledArrays = enabledArrays;
} | java | protected void prepareDraw() {
VertexAttribArrayState previousNio = null;
int previousElementSize = 0;
if (useNioBuffer == 0 && enabledArrays == previouslyEnabledArrays) {
return;
}
for(int i = 0; i < VERTEX_ATTRIB_ARRAY_COUNT; i++) {
int mask = 1 << i;
int enabled = enabledArrays & mask;
if (enabled != (previouslyEnabledArrays & mask)) {
if (enabled != 0) {
gl.enableVertexAttribArray(i);
} else {
gl.disableVertexAttribArray(i);
}
}
if (enabled != 0 && (useNioBuffer & mask) != 0) {
VertexAttribArrayState data = vertexAttribArrayState[i];
if (previousNio != null && previousNio.nioBuffer == data.nioBuffer &&
previousNio.nioBufferLimit >= data.nioBufferLimit) {
if (boundArrayBuffer != previousNio.webGlBuffer) {
gl.bindBuffer(ARRAY_BUFFER, previousNio.webGlBuffer);
boundArrayBuffer = data.webGlBuffer;
}
gl.vertexAttribPointer(i, data.size, data.type, data.normalize, data.stride,
data.nioBufferPosition * previousElementSize);
} else {
if (boundArrayBuffer != data.webGlBuffer) {
gl.bindBuffer(ARRAY_BUFFER, data.webGlBuffer);
boundArrayBuffer = data.webGlBuffer;
}
int elementSize = getElementSize(data.nioBuffer);
int savePosition = data.nioBuffer.position();
if (data.nioBufferPosition * elementSize < data.stride) {
data.nioBuffer.position(0);
gl.bufferData(ARRAY_BUFFER, getTypedArray(data.nioBuffer, data.type, data.nioBufferLimit *
elementSize), STREAM_DRAW);
gl.vertexAttribPointer(i, data.size, data.type, data.normalize, data.stride,
data.nioBufferPosition * elementSize);
previousNio = data;
previousElementSize = elementSize;
} else {
data.nioBuffer.position(data.nioBufferPosition);
gl.bufferData(ARRAY_BUFFER, getTypedArray(data.nioBuffer, data.type,
(data.nioBufferLimit - data.nioBufferPosition) *
elementSize), STREAM_DRAW);
gl.vertexAttribPointer(i, data.size, data.type, data.normalize, data.stride, 0);
}
data.nioBuffer.position(savePosition);
}
}
}
previouslyEnabledArrays = enabledArrays;
} | [
"protected",
"void",
"prepareDraw",
"(",
")",
"{",
"VertexAttribArrayState",
"previousNio",
"=",
"null",
";",
"int",
"previousElementSize",
"=",
"0",
";",
"if",
"(",
"useNioBuffer",
"==",
"0",
"&&",
"enabledArrays",
"==",
"previouslyEnabledArrays",
")",
"{",
"re... | The content of non-VBO buffers may be changed between the glVertexAttribPointer call
and the glDrawXxx call. Thus, we need to defer copying them to a VBO buffer until just
before the actual glDrawXxx call. | [
"The",
"content",
"of",
"non",
"-",
"VBO",
"buffers",
"may",
"be",
"changed",
"between",
"the",
"glVertexAttribPointer",
"call",
"and",
"the",
"glDrawXxx",
"call",
".",
"Thus",
"we",
"need",
"to",
"defer",
"copying",
"them",
"to",
"a",
"VBO",
"buffer",
"un... | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/html/HtmlGL20.java#L239-L294 | train |
playn/playn | jbox2d/src/playn/core/DebugDrawBox2D.java | DebugDrawBox2D.setFillColor | private void setFillColor(Color3f color) {
if (cacheFillR == color.x && cacheFillG == color.y && cacheFillB == color.z) {
// no need to re-set the fill color, just use the cached values
} else {
cacheFillR = color.x;
cacheFillG = color.y;
cacheFillB = color.z;
setFillColorFromCache();
}
} | java | private void setFillColor(Color3f color) {
if (cacheFillR == color.x && cacheFillG == color.y && cacheFillB == color.z) {
// no need to re-set the fill color, just use the cached values
} else {
cacheFillR = color.x;
cacheFillG = color.y;
cacheFillB = color.z;
setFillColorFromCache();
}
} | [
"private",
"void",
"setFillColor",
"(",
"Color3f",
"color",
")",
"{",
"if",
"(",
"cacheFillR",
"==",
"color",
".",
"x",
"&&",
"cacheFillG",
"==",
"color",
".",
"y",
"&&",
"cacheFillB",
"==",
"color",
".",
"z",
")",
"{",
"// no need to re-set the fill color, ... | Sets the fill color from a Color3f
@param color color where (r,g,b) = (x,y,z) | [
"Sets",
"the",
"fill",
"color",
"from",
"a",
"Color3f"
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/jbox2d/src/playn/core/DebugDrawBox2D.java#L175-L184 | train |
playn/playn | jbox2d/src/playn/core/DebugDrawBox2D.java | DebugDrawBox2D.setStrokeColor | private void setStrokeColor(Color3f color) {
if (cacheStrokeR == color.x && cacheStrokeG == color.y && cacheStrokeB == color.z) {
// no need to re-set the stroke color, just use the cached values
} else {
cacheStrokeR = color.x;
cacheStrokeG = color.y;
cacheStrokeB = color.z;
setStrokeColorFromCache();
}
} | java | private void setStrokeColor(Color3f color) {
if (cacheStrokeR == color.x && cacheStrokeG == color.y && cacheStrokeB == color.z) {
// no need to re-set the stroke color, just use the cached values
} else {
cacheStrokeR = color.x;
cacheStrokeG = color.y;
cacheStrokeB = color.z;
setStrokeColorFromCache();
}
} | [
"private",
"void",
"setStrokeColor",
"(",
"Color3f",
"color",
")",
"{",
"if",
"(",
"cacheStrokeR",
"==",
"color",
".",
"x",
"&&",
"cacheStrokeG",
"==",
"color",
".",
"y",
"&&",
"cacheStrokeB",
"==",
"color",
".",
"z",
")",
"{",
"// no need to re-set the stro... | Sets the stroke color from a Color3f
@param color color where (r,g,b) = (x,y,z) | [
"Sets",
"the",
"stroke",
"color",
"from",
"a",
"Color3f"
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/jbox2d/src/playn/core/DebugDrawBox2D.java#L200-L209 | train |
playn/playn | java-base/src/playn/java/JavaPlatform.java | JavaPlatform.start | public void start () {
if (config.activationKey != null) {
input().keyboardEvents.connect(new Slot<Keyboard.Event>() {
public void onEmit (Keyboard.Event event) {
if (event instanceof Keyboard.KeyEvent) {
Keyboard.KeyEvent kevent = (Keyboard.KeyEvent)event;
if (kevent.key == config.activationKey && kevent.down) {
toggleActivation();
}
}
}
});
}
// make a note of the main thread
synchronized (this) {
mainThread = Thread.currentThread();
}
// run the game loop
loop();
// let the game run any of its exit hooks
dispatchEvent(lifecycle, Lifecycle.EXIT);
// shutdown our thread pool
try {
pool.shutdown();
pool.awaitTermination(1, TimeUnit.SECONDS);
} catch (InterruptedException ie) {
// nothing to do here except go ahead and exit
}
// and finally stick a fork in the JVM
System.exit(0);
} | java | public void start () {
if (config.activationKey != null) {
input().keyboardEvents.connect(new Slot<Keyboard.Event>() {
public void onEmit (Keyboard.Event event) {
if (event instanceof Keyboard.KeyEvent) {
Keyboard.KeyEvent kevent = (Keyboard.KeyEvent)event;
if (kevent.key == config.activationKey && kevent.down) {
toggleActivation();
}
}
}
});
}
// make a note of the main thread
synchronized (this) {
mainThread = Thread.currentThread();
}
// run the game loop
loop();
// let the game run any of its exit hooks
dispatchEvent(lifecycle, Lifecycle.EXIT);
// shutdown our thread pool
try {
pool.shutdown();
pool.awaitTermination(1, TimeUnit.SECONDS);
} catch (InterruptedException ie) {
// nothing to do here except go ahead and exit
}
// and finally stick a fork in the JVM
System.exit(0);
} | [
"public",
"void",
"start",
"(",
")",
"{",
"if",
"(",
"config",
".",
"activationKey",
"!=",
"null",
")",
"{",
"input",
"(",
")",
".",
"keyboardEvents",
".",
"connect",
"(",
"new",
"Slot",
"<",
"Keyboard",
".",
"Event",
">",
"(",
")",
"{",
"public",
... | Starts the game loop. This method will not return until the game exits. | [
"Starts",
"the",
"game",
"loop",
".",
"This",
"method",
"will",
"not",
"return",
"until",
"the",
"game",
"exits",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/java-base/src/playn/java/JavaPlatform.java#L128-L163 | train |
playn/playn | html/src/playn/super/java/nio/IntBuffer.java | IntBuffer.allocate | public static IntBuffer allocate (int capacity) {
if (capacity < 0) {
throw new IllegalArgumentException();
}
ByteBuffer bb = ByteBuffer.allocateDirect(capacity * 4);
bb.order(ByteOrder.nativeOrder());
return bb.asIntBuffer();
} | java | public static IntBuffer allocate (int capacity) {
if (capacity < 0) {
throw new IllegalArgumentException();
}
ByteBuffer bb = ByteBuffer.allocateDirect(capacity * 4);
bb.order(ByteOrder.nativeOrder());
return bb.asIntBuffer();
} | [
"public",
"static",
"IntBuffer",
"allocate",
"(",
"int",
"capacity",
")",
"{",
"if",
"(",
"capacity",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"ByteBuffer",
"bb",
"=",
"ByteBuffer",
".",
"allocateDirect",
"(",
"ca... | Creates an int buffer based on a newly allocated int array.
@param capacity the capacity of the new buffer.
@return the created int buffer.
@throws IllegalArgumentException if {@code capacity} is less than zero. | [
"Creates",
"an",
"int",
"buffer",
"based",
"on",
"a",
"newly",
"allocated",
"int",
"array",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/super/java/nio/IntBuffer.java#L52-L59 | train |
playn/playn | html/src/playn/super/java/nio/IntBuffer.java | IntBuffer.compareTo | public int compareTo (IntBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ?
remaining() : otherBuffer.remaining();
int thisPos = position;
int otherPos = otherBuffer.position;
// BEGIN android-changed
int thisInt, otherInt;
while (compareRemaining > 0) {
thisInt = get(thisPos);
otherInt = otherBuffer.get(otherPos);
if (thisInt != otherInt) {
return thisInt < otherInt ? -1 : 1;
}
thisPos++;
otherPos++;
compareRemaining--;
}
// END android-changed
return remaining() - otherBuffer.remaining();
} | java | public int compareTo (IntBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ?
remaining() : otherBuffer.remaining();
int thisPos = position;
int otherPos = otherBuffer.position;
// BEGIN android-changed
int thisInt, otherInt;
while (compareRemaining > 0) {
thisInt = get(thisPos);
otherInt = otherBuffer.get(otherPos);
if (thisInt != otherInt) {
return thisInt < otherInt ? -1 : 1;
}
thisPos++;
otherPos++;
compareRemaining--;
}
// END android-changed
return remaining() - otherBuffer.remaining();
} | [
"public",
"int",
"compareTo",
"(",
"IntBuffer",
"otherBuffer",
")",
"{",
"int",
"compareRemaining",
"=",
"(",
"remaining",
"(",
")",
"<",
"otherBuffer",
".",
"remaining",
"(",
")",
")",
"?",
"remaining",
"(",
")",
":",
"otherBuffer",
".",
"remaining",
"(",... | Compares the remaining ints of this buffer to another int buffer's remaining ints.
@param otherBuffer another int buffer.
@return a negative value if this is less than {@code other}; 0 if this equals to {@code
other}; a positive value if this is greater than {@code other}.
@exception ClassCastException if {@code other} is not an int buffer. | [
"Compares",
"the",
"remaining",
"ints",
"of",
"this",
"buffer",
"to",
"another",
"int",
"buffer",
"s",
"remaining",
"ints",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/super/java/nio/IntBuffer.java#L96-L115 | train |
playn/playn | core/src/playn/core/TextFormat.java | TextFormat.withFont | public TextFormat withFont(String name, Font.Style style, float size) {
return withFont(new Font(name, style, size));
} | java | public TextFormat withFont(String name, Font.Style style, float size) {
return withFont(new Font(name, style, size));
} | [
"public",
"TextFormat",
"withFont",
"(",
"String",
"name",
",",
"Font",
".",
"Style",
"style",
",",
"float",
"size",
")",
"{",
"return",
"withFont",
"(",
"new",
"Font",
"(",
"name",
",",
"style",
",",
"size",
")",
")",
";",
"}"
] | Returns a clone of this text format with the font configured as specified. | [
"Returns",
"a",
"clone",
"of",
"this",
"text",
"format",
"with",
"the",
"font",
"configured",
"as",
"specified",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/TextFormat.java#L51-L53 | train |
playn/playn | core/src/playn/core/Assets.java | Assets.getImageSync | public Image getImageSync (String path) {
ImageImpl image = createImage(false, 0, 0, path);
try {
image.succeed(load(path));
} catch (Throwable t) {
image.fail(t);
}
return image;
} | java | public Image getImageSync (String path) {
ImageImpl image = createImage(false, 0, 0, path);
try {
image.succeed(load(path));
} catch (Throwable t) {
image.fail(t);
}
return image;
} | [
"public",
"Image",
"getImageSync",
"(",
"String",
"path",
")",
"{",
"ImageImpl",
"image",
"=",
"createImage",
"(",
"false",
",",
"0",
",",
"0",
",",
"path",
")",
";",
"try",
"{",
"image",
".",
"succeed",
"(",
"load",
"(",
"path",
")",
")",
";",
"}"... | Synchronously loads and returns an image. The calling thread will block while the image is
loaded from disk and decoded. When this call returns, the image's width and height will be
valid, and the image can be immediately converted to a texture and drawn into a canvas.
@param path the path to the image asset.
@throws UnsupportedOperationException on platforms that cannot support synchronous asset
loading (HTML). | [
"Synchronously",
"loads",
"and",
"returns",
"an",
"image",
".",
"The",
"calling",
"thread",
"will",
"block",
"while",
"the",
"image",
"is",
"loaded",
"from",
"disk",
"and",
"decoded",
".",
"When",
"this",
"call",
"returns",
"the",
"image",
"s",
"width",
"a... | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Assets.java#L37-L45 | train |
playn/playn | core/src/playn/core/Assets.java | Assets.getText | public RFuture<String> getText (final String path) {
final RPromise<String> result = exec.deferredPromise();
exec.invokeAsync(new Runnable() {
public void run () {
try {
result.succeed(getTextSync(path));
} catch (Throwable t) {
result.fail(t);
}
}
});
return result;
} | java | public RFuture<String> getText (final String path) {
final RPromise<String> result = exec.deferredPromise();
exec.invokeAsync(new Runnable() {
public void run () {
try {
result.succeed(getTextSync(path));
} catch (Throwable t) {
result.fail(t);
}
}
});
return result;
} | [
"public",
"RFuture",
"<",
"String",
">",
"getText",
"(",
"final",
"String",
"path",
")",
"{",
"final",
"RPromise",
"<",
"String",
">",
"result",
"=",
"exec",
".",
"deferredPromise",
"(",
")",
";",
"exec",
".",
"invokeAsync",
"(",
"new",
"Runnable",
"(",
... | Loads UTF-8 encoded text asynchronously. The returned state instance provides a means to
listen for the arrival of the text.
@param path the path to the text asset. | [
"Loads",
"UTF",
"-",
"8",
"encoded",
"text",
"asynchronously",
".",
"The",
"returned",
"state",
"instance",
"provides",
"a",
"means",
"to",
"listen",
"for",
"the",
"arrival",
"of",
"the",
"text",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Assets.java#L135-L147 | train |
playn/playn | core/src/playn/core/Assets.java | Assets.getBytes | public RFuture<ByteBuffer> getBytes (final String path) {
final RPromise<ByteBuffer> result = exec.deferredPromise();
exec.invokeAsync(new Runnable() {
public void run () {
try {
result.succeed(getBytesSync(path));
} catch (Throwable t) {
result.fail(t);
}
}
});
return result;
} | java | public RFuture<ByteBuffer> getBytes (final String path) {
final RPromise<ByteBuffer> result = exec.deferredPromise();
exec.invokeAsync(new Runnable() {
public void run () {
try {
result.succeed(getBytesSync(path));
} catch (Throwable t) {
result.fail(t);
}
}
});
return result;
} | [
"public",
"RFuture",
"<",
"ByteBuffer",
">",
"getBytes",
"(",
"final",
"String",
"path",
")",
"{",
"final",
"RPromise",
"<",
"ByteBuffer",
">",
"result",
"=",
"exec",
".",
"deferredPromise",
"(",
")",
";",
"exec",
".",
"invokeAsync",
"(",
"new",
"Runnable"... | Loads binary data asynchronously. The returned state instance provides a means to listen for
the arrival of the data.
@param path the path to the binary asset. | [
"Loads",
"binary",
"data",
"asynchronously",
".",
"The",
"returned",
"state",
"instance",
"provides",
"a",
"means",
"to",
"listen",
"for",
"the",
"arrival",
"of",
"the",
"data",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Assets.java#L165-L177 | train |
playn/playn | html/src/playn/html/HtmlInput.java | HtmlInput.getRelativeX | static float getRelativeX (NativeEvent e, Element target) {
return (e.getClientX() - target.getAbsoluteLeft() + target.getScrollLeft() +
target.getOwnerDocument().getScrollLeft()) / HtmlGraphics.experimentalScale;
} | java | static float getRelativeX (NativeEvent e, Element target) {
return (e.getClientX() - target.getAbsoluteLeft() + target.getScrollLeft() +
target.getOwnerDocument().getScrollLeft()) / HtmlGraphics.experimentalScale;
} | [
"static",
"float",
"getRelativeX",
"(",
"NativeEvent",
"e",
",",
"Element",
"target",
")",
"{",
"return",
"(",
"e",
".",
"getClientX",
"(",
")",
"-",
"target",
".",
"getAbsoluteLeft",
"(",
")",
"+",
"target",
".",
"getScrollLeft",
"(",
")",
"+",
"target"... | Gets the event's x-position relative to a given element.
@param e native event
@param target the element whose coordinate system is to be used
@return the relative x-position | [
"Gets",
"the",
"event",
"s",
"x",
"-",
"position",
"relative",
"to",
"a",
"given",
"element",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/html/HtmlInput.java#L311-L314 | train |
playn/playn | html/src/playn/html/HtmlInput.java | HtmlInput.getRelativeY | static float getRelativeY (NativeEvent e, Element target) {
return (e.getClientY() - target.getAbsoluteTop() + target.getScrollTop() +
target.getOwnerDocument().getScrollTop()) / HtmlGraphics.experimentalScale;
} | java | static float getRelativeY (NativeEvent e, Element target) {
return (e.getClientY() - target.getAbsoluteTop() + target.getScrollTop() +
target.getOwnerDocument().getScrollTop()) / HtmlGraphics.experimentalScale;
} | [
"static",
"float",
"getRelativeY",
"(",
"NativeEvent",
"e",
",",
"Element",
"target",
")",
"{",
"return",
"(",
"e",
".",
"getClientY",
"(",
")",
"-",
"target",
".",
"getAbsoluteTop",
"(",
")",
"+",
"target",
".",
"getScrollTop",
"(",
")",
"+",
"target",
... | Gets the event's y-position relative to a given element.
@param e native event
@param target the element whose coordinate system is to be used
@return the relative y-position | [
"Gets",
"the",
"event",
"s",
"y",
"-",
"position",
"relative",
"to",
"a",
"given",
"element",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/html/HtmlInput.java#L323-L326 | train |
playn/playn | core/src/playn/core/ImageImpl.java | ImageImpl.succeed | public synchronized void succeed (Data data) {
scale = data.scale;
pixelWidth = data.pixelWidth;
assert pixelWidth > 0;
pixelHeight = data.pixelHeight;
assert pixelHeight > 0;
setBitmap(data.bitmap);
((RPromise<Image>)state).succeed(this); // state is a deferred promise
} | java | public synchronized void succeed (Data data) {
scale = data.scale;
pixelWidth = data.pixelWidth;
assert pixelWidth > 0;
pixelHeight = data.pixelHeight;
assert pixelHeight > 0;
setBitmap(data.bitmap);
((RPromise<Image>)state).succeed(this); // state is a deferred promise
} | [
"public",
"synchronized",
"void",
"succeed",
"(",
"Data",
"data",
")",
"{",
"scale",
"=",
"data",
".",
"scale",
";",
"pixelWidth",
"=",
"data",
".",
"pixelWidth",
";",
"assert",
"pixelWidth",
">",
"0",
";",
"pixelHeight",
"=",
"data",
".",
"pixelHeight",
... | Notifies this image that its implementation bitmap is available.
This can be called from any thread. | [
"Notifies",
"this",
"image",
"that",
"its",
"implementation",
"bitmap",
"is",
"available",
".",
"This",
"can",
"be",
"called",
"from",
"any",
"thread",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/ImageImpl.java#L43-L51 | train |
playn/playn | core/src/playn/core/ImageImpl.java | ImageImpl.fail | public synchronized void fail (Throwable error) {
if (pixelWidth == 0) pixelWidth = 50;
if (pixelHeight == 0) pixelHeight = 50;
setBitmap(createErrorBitmap(pixelWidth, pixelHeight));
((RPromise<Image>)state).fail(error); // state is a deferred promise
} | java | public synchronized void fail (Throwable error) {
if (pixelWidth == 0) pixelWidth = 50;
if (pixelHeight == 0) pixelHeight = 50;
setBitmap(createErrorBitmap(pixelWidth, pixelHeight));
((RPromise<Image>)state).fail(error); // state is a deferred promise
} | [
"public",
"synchronized",
"void",
"fail",
"(",
"Throwable",
"error",
")",
"{",
"if",
"(",
"pixelWidth",
"==",
"0",
")",
"pixelWidth",
"=",
"50",
";",
"if",
"(",
"pixelHeight",
"==",
"0",
")",
"pixelHeight",
"=",
"50",
";",
"setBitmap",
"(",
"createErrorB... | Notifies this image that its implementation bitmap failed to load.
This can be called from any thread. | [
"Notifies",
"this",
"image",
"that",
"its",
"implementation",
"bitmap",
"failed",
"to",
"load",
".",
"This",
"can",
"be",
"called",
"from",
"any",
"thread",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/ImageImpl.java#L55-L60 | train |
playn/playn | html/src/playn/appcachelinker/AppCacheLinker.java | AppCacheLinker.accept | protected boolean accept(String path) {
// GWT Development Mode files
if (path.equals("hosted.html") || path.endsWith(".devmode.js")) {
return false;
}
// Default or welcome file
if (path.equals("/")) {
return true;
}
// Whitelisted file extension
int pos = path.lastIndexOf('.');
if (pos != -1) {
String extension = path.substring(pos + 1);
if (DEFAULT_EXTENSION_WHITELIST.contains(extension)) {
return true;
}
}
// Not included by default
return false;
} | java | protected boolean accept(String path) {
// GWT Development Mode files
if (path.equals("hosted.html") || path.endsWith(".devmode.js")) {
return false;
}
// Default or welcome file
if (path.equals("/")) {
return true;
}
// Whitelisted file extension
int pos = path.lastIndexOf('.');
if (pos != -1) {
String extension = path.substring(pos + 1);
if (DEFAULT_EXTENSION_WHITELIST.contains(extension)) {
return true;
}
}
// Not included by default
return false;
} | [
"protected",
"boolean",
"accept",
"(",
"String",
"path",
")",
"{",
"// GWT Development Mode files",
"if",
"(",
"path",
".",
"equals",
"(",
"\"hosted.html\"",
")",
"||",
"path",
".",
"endsWith",
"(",
"\".devmode.js\"",
")",
")",
"{",
"return",
"false",
";",
"... | Determines whether our not the given should be included in the app cache
manifest. Subclasses may override this method in order to filter out
specific file patterns.
@param path the path of the resource being considered
@return true if the file should be included in the manifest | [
"Determines",
"whether",
"our",
"not",
"the",
"given",
"should",
"be",
"included",
"in",
"the",
"app",
"cache",
"manifest",
".",
"Subclasses",
"may",
"override",
"this",
"method",
"in",
"order",
"to",
"filter",
"out",
"specific",
"file",
"patterns",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/appcachelinker/AppCacheLinker.java#L99-L122 | train |
playn/playn | core/src/playn/core/Graphics.java | Graphics.createTexture | public Texture createTexture (float width, float height, Texture.Config config) {
int texWidth = config.toTexWidth(scale.scaledCeil(width));
int texHeight = config.toTexHeight(scale.scaledCeil(height));
if (texWidth <= 0 || texHeight <= 0) throw new IllegalArgumentException(
"Invalid texture size: " + texWidth + "x" + texHeight);
int id = createTexture(config);
gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight,
0, GL_RGBA, GL_UNSIGNED_BYTE, null);
return new Texture(this, id, config, texWidth, texHeight, scale, width, height);
} | java | public Texture createTexture (float width, float height, Texture.Config config) {
int texWidth = config.toTexWidth(scale.scaledCeil(width));
int texHeight = config.toTexHeight(scale.scaledCeil(height));
if (texWidth <= 0 || texHeight <= 0) throw new IllegalArgumentException(
"Invalid texture size: " + texWidth + "x" + texHeight);
int id = createTexture(config);
gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight,
0, GL_RGBA, GL_UNSIGNED_BYTE, null);
return new Texture(this, id, config, texWidth, texHeight, scale, width, height);
} | [
"public",
"Texture",
"createTexture",
"(",
"float",
"width",
",",
"float",
"height",
",",
"Texture",
".",
"Config",
"config",
")",
"{",
"int",
"texWidth",
"=",
"config",
".",
"toTexWidth",
"(",
"scale",
".",
"scaledCeil",
"(",
"width",
")",
")",
";",
"in... | Creates an empty texture into which one can render. The supplied width and height are in
display units and will be converted to pixels based on the current scale factor. | [
"Creates",
"an",
"empty",
"texture",
"into",
"which",
"one",
"can",
"render",
".",
"The",
"supplied",
"width",
"and",
"height",
"are",
"in",
"display",
"units",
"and",
"will",
"be",
"converted",
"to",
"pixels",
"based",
"on",
"the",
"current",
"scale",
"fa... | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Graphics.java#L124-L134 | train |
playn/playn | core/src/playn/core/Graphics.java | Graphics.viewportChanged | protected void viewportChanged (int pixelWidth, int pixelHeight) {
viewPixelWidth = pixelWidth;
viewPixelHeight = pixelHeight;
viewSizeM.width = scale.invScaled(pixelWidth);
viewSizeM.height = scale.invScaled(pixelHeight);
plat.log().info("viewPortChanged " + pixelWidth + "x" + pixelHeight + " / " + scale.factor +
" -> " + viewSize);
} | java | protected void viewportChanged (int pixelWidth, int pixelHeight) {
viewPixelWidth = pixelWidth;
viewPixelHeight = pixelHeight;
viewSizeM.width = scale.invScaled(pixelWidth);
viewSizeM.height = scale.invScaled(pixelHeight);
plat.log().info("viewPortChanged " + pixelWidth + "x" + pixelHeight + " / " + scale.factor +
" -> " + viewSize);
} | [
"protected",
"void",
"viewportChanged",
"(",
"int",
"pixelWidth",
",",
"int",
"pixelHeight",
")",
"{",
"viewPixelWidth",
"=",
"pixelWidth",
";",
"viewPixelHeight",
"=",
"pixelHeight",
";",
"viewSizeM",
".",
"width",
"=",
"scale",
".",
"invScaled",
"(",
"pixelWid... | Informs the graphics system that the main framebuffer size has changed. The supplied size
should be in physical pixels. | [
"Informs",
"the",
"graphics",
"system",
"that",
"the",
"main",
"framebuffer",
"size",
"has",
"changed",
".",
"The",
"supplied",
"size",
"should",
"be",
"in",
"physical",
"pixels",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/Graphics.java#L196-L203 | train |
playn/playn | html/src/playn/super/java/nio/ShortBuffer.java | ShortBuffer.allocate | public static ShortBuffer allocate (int capacity) {
if (capacity < 0) {
throw new IllegalArgumentException();
}
ByteBuffer bb = ByteBuffer.allocateDirect(capacity * 2);
bb.order(ByteOrder.nativeOrder());
return bb.asShortBuffer();
} | java | public static ShortBuffer allocate (int capacity) {
if (capacity < 0) {
throw new IllegalArgumentException();
}
ByteBuffer bb = ByteBuffer.allocateDirect(capacity * 2);
bb.order(ByteOrder.nativeOrder());
return bb.asShortBuffer();
} | [
"public",
"static",
"ShortBuffer",
"allocate",
"(",
"int",
"capacity",
")",
"{",
"if",
"(",
"capacity",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"ByteBuffer",
"bb",
"=",
"ByteBuffer",
".",
"allocateDirect",
"(",
"... | Creates a short buffer based on a newly allocated short array.
@param capacity the capacity of the new buffer.
@return the created short buffer.
@throws IllegalArgumentException if {@code capacity} is less than zero. | [
"Creates",
"a",
"short",
"buffer",
"based",
"on",
"a",
"newly",
"allocated",
"short",
"array",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/html/src/playn/super/java/nio/ShortBuffer.java#L49-L56 | train |
playn/playn | core/src/playn/core/json/JsonParser.java | JsonParser.parse | @SuppressWarnings("unchecked")
<T> T parse(Class<T> clazz) throws JsonParserException {
advanceToken();
Object parsed = currentValue();
if (advanceToken() != Token.EOF)
throw createParseException(null, "Expected end of input, got " + token, true);
if (clazz != Object.class && (parsed == null || clazz != parsed.getClass()))
throw createParseException(null, "JSON did not contain the correct type, expected " + clazz.getName()
+ ".", true);
return (T)(parsed);
} | java | @SuppressWarnings("unchecked")
<T> T parse(Class<T> clazz) throws JsonParserException {
advanceToken();
Object parsed = currentValue();
if (advanceToken() != Token.EOF)
throw createParseException(null, "Expected end of input, got " + token, true);
if (clazz != Object.class && (parsed == null || clazz != parsed.getClass()))
throw createParseException(null, "JSON did not contain the correct type, expected " + clazz.getName()
+ ".", true);
return (T)(parsed);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"<",
"T",
">",
"T",
"parse",
"(",
"Class",
"<",
"T",
">",
"clazz",
")",
"throws",
"JsonParserException",
"{",
"advanceToken",
"(",
")",
";",
"Object",
"parsed",
"=",
"currentValue",
"(",
")",
";",
"if",... | Parse a single JSON value from the string, expecting an EOF at the end. | [
"Parse",
"a",
"single",
"JSON",
"value",
"from",
"the",
"string",
"expecting",
"an",
"EOF",
"at",
"the",
"end",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/json/JsonParser.java#L120-L130 | train |
playn/playn | core/src/playn/core/json/JsonParser.java | JsonParser.currentValue | private Object currentValue() throws JsonParserException {
// Only a value start token should appear when we're in the context of parsing a JSON value
if (token.isValue)
return value;
throw createParseException(null, "Expected JSON value, got " + token, true);
} | java | private Object currentValue() throws JsonParserException {
// Only a value start token should appear when we're in the context of parsing a JSON value
if (token.isValue)
return value;
throw createParseException(null, "Expected JSON value, got " + token, true);
} | [
"private",
"Object",
"currentValue",
"(",
")",
"throws",
"JsonParserException",
"{",
"// Only a value start token should appear when we're in the context of parsing a JSON value",
"if",
"(",
"token",
".",
"isValue",
")",
"return",
"value",
";",
"throw",
"createParseException",
... | Starts parsing a JSON value at the current token position. | [
"Starts",
"parsing",
"a",
"JSON",
"value",
"at",
"the",
"current",
"token",
"position",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/json/JsonParser.java#L135-L140 | train |
playn/playn | core/src/playn/core/json/JsonParser.java | JsonParser.consumeKeyword | private void consumeKeyword(char first, char[] expected) throws JsonParserException {
for (int i = 0; i < expected.length; i++)
if (advanceChar() != expected[i])
throw createHelpfulException(first, expected, i);
// The token should end with something other than an ASCII letter
if (isAsciiLetter(peekChar()))
throw createHelpfulException(first, expected, expected.length);
} | java | private void consumeKeyword(char first, char[] expected) throws JsonParserException {
for (int i = 0; i < expected.length; i++)
if (advanceChar() != expected[i])
throw createHelpfulException(first, expected, i);
// The token should end with something other than an ASCII letter
if (isAsciiLetter(peekChar()))
throw createHelpfulException(first, expected, expected.length);
} | [
"private",
"void",
"consumeKeyword",
"(",
"char",
"first",
",",
"char",
"[",
"]",
"expected",
")",
"throws",
"JsonParserException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"expected",
".",
"length",
";",
"i",
"++",
")",
"if",
"(",
"adva... | Expects a given string at the current position. | [
"Expects",
"a",
"given",
"string",
"at",
"the",
"current",
"position",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/json/JsonParser.java#L245-L253 | train |
playn/playn | core/src/playn/core/json/JsonParser.java | JsonParser.stringChar | private char stringChar() throws JsonParserException {
int c = advanceChar();
if (c == -1)
throw createParseException(null, "String was not terminated before end of input", true);
if (c < 32)
throw createParseException(null,
"Strings may not contain control characters: 0x" + Integer.toString(c, 16), false);
return (char)c;
} | java | private char stringChar() throws JsonParserException {
int c = advanceChar();
if (c == -1)
throw createParseException(null, "String was not terminated before end of input", true);
if (c < 32)
throw createParseException(null,
"Strings may not contain control characters: 0x" + Integer.toString(c, 16), false);
return (char)c;
} | [
"private",
"char",
"stringChar",
"(",
")",
"throws",
"JsonParserException",
"{",
"int",
"c",
"=",
"advanceChar",
"(",
")",
";",
"if",
"(",
"c",
"==",
"-",
"1",
")",
"throw",
"createParseException",
"(",
"null",
",",
"\"String was not terminated before end of inp... | Advances a character, throwing if it is illegal in the context of a JSON string. | [
"Advances",
"a",
"character",
"throwing",
"if",
"it",
"is",
"illegal",
"in",
"the",
"context",
"of",
"a",
"JSON",
"string",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/json/JsonParser.java#L373-L381 | train |
playn/playn | core/src/playn/core/json/JsonParser.java | JsonParser.stringHexChar | private int stringHexChar() throws JsonParserException {
// GWT-compatible Character.digit(char, int)
int c = "0123456789abcdef0123456789ABCDEF".indexOf(advanceChar()) % 16;
if (c == -1)
throw createParseException(null, "Expected unicode hex escape character", false);
return c;
} | java | private int stringHexChar() throws JsonParserException {
// GWT-compatible Character.digit(char, int)
int c = "0123456789abcdef0123456789ABCDEF".indexOf(advanceChar()) % 16;
if (c == -1)
throw createParseException(null, "Expected unicode hex escape character", false);
return c;
} | [
"private",
"int",
"stringHexChar",
"(",
")",
"throws",
"JsonParserException",
"{",
"// GWT-compatible Character.digit(char, int)",
"int",
"c",
"=",
"\"0123456789abcdef0123456789ABCDEF\"",
".",
"indexOf",
"(",
"advanceChar",
"(",
")",
")",
"%",
"16",
";",
"if",
"(",
... | Advances a character, throwing if it is illegal in the context of a JSON string hex unicode escape. | [
"Advances",
"a",
"character",
"throwing",
"if",
"it",
"is",
"illegal",
"in",
"the",
"context",
"of",
"a",
"JSON",
"string",
"hex",
"unicode",
"escape",
"."
] | 7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66 | https://github.com/playn/playn/blob/7e7a9d048ba6afe550dc0cdeaca3e1d5b0d01c66/core/src/playn/core/json/JsonParser.java#L386-L392 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.