blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
listlengths 1
1
| author_id
stringlengths 0
313
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
50a2dabdb5288a26fedc6bfd83da704a2baf843c
|
028cbe18b4e5c347f664c592cbc7f56729b74060
|
/external/modules/derby/10.10.2.0/java/engine/org/apache/derby/iapi/services/io/FileUtil.java
|
060a3a42abf84d9a7584eb0ad03917a94bea60a7
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-generic-export-compliance"
] |
permissive
|
dmatej/Glassfish-SVN-Patched
|
8d355ff753b23a9a1bd9d7475fa4b2cfd3b40f9e
|
269e29ba90db6d9c38271f7acd2affcacf2416f1
|
refs/heads/master
| 2021-05-28T12:55:06.267463
| 2014-11-11T04:21:44
| 2014-11-11T04:21:44
| 23,610,469
| 1
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 31,256
|
java
|
/*
Derby - Class org.apache.derby.iapi.services.io.FileUtil
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to you under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.apache.derby.iapi.services.io;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Field;
import org.apache.derby.io.StorageFactory;
import org.apache.derby.io.WritableStorageFactory;
import org.apache.derby.io.StorageFile;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.derby.iapi.reference.Property;
import org.apache.derby.iapi.services.info.JVMInfo;
import org.apache.derby.iapi.services.property.PropertyUtil;
import org.apache.derby.shared.common.sanity.SanityManager;
/**
A set of public static methods for dealing with File objects.
*/
public abstract class FileUtil {
private static final int BUFFER_SIZE = 4096*4;
/**
Remove a directory and all of its contents.
The results of executing File.delete() on a File object
that represents a directory seems to be platform
dependent. This method removes the directory
and all of its contents.
@return true if the complete directory was removed, false if it could not be.
If false is returned then some of the files in the directory may have been removed.
*/
public static boolean removeDirectory(File directory) {
// System.out.println("removeDirectory " + directory);
if (directory == null)
return false;
if (!directory.exists())
return true;
if (!directory.isDirectory())
return false;
String[] list = directory.list();
// Some JVMs return null for File.list() when the
// directory is empty.
if (list != null) {
for (int i = 0; i < list.length; i++) {
File entry = new File(directory, list[i]);
// System.out.println("\tremoving entry " + entry);
if (entry.isDirectory())
{
if (!removeDirectory(entry))
return false;
}
else
{
if (!entry.delete())
return false;
}
}
}
return directory.delete();
}
public static boolean removeDirectory(String directory)
{
return removeDirectory(new File(directory));
}
/**
Copy a directory and all of its contents.
*/
public static boolean copyDirectory(File from, File to)
{
return copyDirectory(from, to, (byte[])null, (String[])null);
}
public static boolean copyDirectory(String from, String to)
{
return copyDirectory(new File(from), new File(to));
}
/**
@param filter - array of names to not copy.
*/
public static boolean copyDirectory(File from, File to, byte[] buffer,
String[] filter)
{
//
// System.out.println("copyDirectory("+from+","+to+")");
if (from == null)
return false;
if (!from.exists())
return true;
if (!from.isDirectory())
return false;
if (to.exists())
{
// System.out.println(to + " exists");
return false;
}
if (!to.mkdirs())
{
// System.out.println("can't make" + to);
return false;
}
limitAccessToOwner(to);
String[] list = from.list();
// Some JVMs return null for File.list() when the
// directory is empty.
if (list != null) {
if (buffer == null)
buffer = new byte[BUFFER_SIZE]; // reuse this buffer to copy files
nextFile: for (int i = 0; i < list.length; i++) {
String fileName = list[i];
if (filter != null) {
for (int j = 0; j < filter.length; j++) {
if (fileName.equals(filter[j]))
continue nextFile;
}
}
File entry = new File(from, fileName);
// System.out.println("\tcopying entry " + entry);
if (entry.isDirectory())
{
if (!copyDirectory(entry,new File(to,fileName),buffer,filter))
return false;
}
else
{
if (!copyFile(entry,new File(to,fileName),buffer))
return false;
}
}
}
return true;
}
public static boolean copyFile(File from, File to, byte[] buf)
{
if (buf == null)
buf = new byte[BUFFER_SIZE];
//
// System.out.println("Copy file ("+from+","+to+")");
FileInputStream from_s = null;
FileOutputStream to_s = null;
try {
from_s = new FileInputStream(from);
to_s = new FileOutputStream(to);
limitAccessToOwner(to);
for (int bytesRead = from_s.read(buf);
bytesRead != -1;
bytesRead = from_s.read(buf))
to_s.write(buf,0,bytesRead);
from_s.close();
from_s = null;
to_s.getFD().sync(); // RESOLVE: sync or no sync?
to_s.close();
to_s = null;
}
catch (IOException ioe)
{
return false;
}
finally
{
if (from_s != null)
{
try { from_s.close(); }
catch (IOException ioe) {}
}
if (to_s != null)
{
try { to_s.close(); }
catch (IOException ioe) {}
}
}
return true;
}
public static boolean copyDirectory( StorageFactory storageFactory,
StorageFile from,
File to,
byte[] buffer,
String[] filter,
boolean copySubDirs)
{
if (from == null)
return false;
if (!from.exists())
return true;
if (!from.isDirectory())
return false;
if (to.exists())
{
// System.out.println(to + " exists");
return false;
}
if (!to.mkdirs())
{
// System.out.println("can't make" + to);
return false;
}
limitAccessToOwner(to);
String[] list = from.list();
// Some JVMs return null for File.list() when the
// directory is empty.
if (list != null)
{
if (buffer == null)
buffer = new byte[BUFFER_SIZE]; // reuse this buffer to copy files
nextFile:
for (int i = 0; i < list.length; i++)
{
String fileName = list[i];
if (filter != null) {
for (int j = 0; j < filter.length; j++) {
if (fileName.equals(filter[j]))
continue nextFile;
}
}
StorageFile entry = storageFactory.newStorageFile(from, fileName);
if (entry.isDirectory())
{
if(copySubDirs) {
if (!copyDirectory( storageFactory, entry,
new File(to,fileName), buffer,
filter, copySubDirs))
return false;
}
else {
// the request is to not copy the directories, continue
// to the next file in the list.
continue nextFile;
}
}
else
{
if (!copyFile( storageFactory, entry, new File(to,fileName), buffer))
return false;
}
}
}
return true;
} // end of copyDirectory( StorageFactory sf, StorageFile from, File to, byte[] buf, String[] filter)
public static boolean copyFile( StorageFactory storageFactory, StorageFile from, File to)
{
return copyFile( storageFactory, from, to, (byte[]) null);
}
public static boolean copyFile( StorageFactory storageFactory, StorageFile from, File to, byte[] buf)
{
InputStream from_s = null;
FileOutputStream to_s = null;
try {
from_s = from.getInputStream();
to_s = new FileOutputStream( to);
limitAccessToOwner(to);
if (buf == null)
buf = new byte[BUFFER_SIZE]; // reuse this buffer to copy files
for (int bytesRead = from_s.read(buf);
bytesRead != -1;
bytesRead = from_s.read(buf))
to_s.write(buf,0,bytesRead);
from_s.close();
from_s = null;
to_s.getFD().sync(); // RESOLVE: sync or no sync?
to_s.close();
to_s = null;
}
catch (IOException ioe)
{
return false;
}
finally
{
if (from_s != null)
{
try { from_s.close(); }
catch (IOException ioe) {}
}
if (to_s != null)
{
try { to_s.close(); }
catch (IOException ioe) {}
}
}
return true;
} // end of copyFile( StorageFactory storageFactory, StorageFile from, File to, byte[] buf)
public static boolean copyDirectory( WritableStorageFactory storageFactory,
File from,
StorageFile to)
{
return copyDirectory( storageFactory, from, to, null, null);
}
public static boolean copyDirectory( WritableStorageFactory storageFactory,
File from,
StorageFile to,
byte[] buffer,
String[] filter)
{
if (from == null)
return false;
if (!from.exists())
return true;
if (!from.isDirectory())
return false;
if (to.exists())
{
// System.out.println(to + " exists");
return false;
}
if (!to.mkdirs())
{
// System.out.println("can't make" + to);
return false;
}
to.limitAccessToOwner();
String[] list = from.list();
// Some JVMs return null for File.list() when the
// directory is empty.
if (list != null)
{
if (buffer == null)
buffer = new byte[BUFFER_SIZE]; // reuse this buffer to copy files
nextFile:
for (int i = 0; i < list.length; i++)
{
String fileName = list[i];
if (filter != null) {
for (int j = 0; j < filter.length; j++) {
if (fileName.equals(filter[j]))
continue nextFile;
}
}
File entry = new File(from, fileName);
if (entry.isDirectory())
{
if (!copyDirectory( storageFactory, entry, storageFactory.newStorageFile(to,fileName), buffer, filter))
return false;
}
else
{
if (!copyFile( storageFactory, entry, storageFactory.newStorageFile(to,fileName), buffer))
return false;
}
}
}
return true;
} // end of copyDirectory( StorageFactory sf, StorageFile from, File to, byte[] buf, String[] filter)
public static boolean copyFile( WritableStorageFactory storageFactory, File from, StorageFile to)
{
return copyFile( storageFactory, from, to, (byte[]) null);
}
public static boolean copyFile( WritableStorageFactory storageFactory, File from, StorageFile to, byte[] buf)
{
InputStream from_s = null;
OutputStream to_s = null;
try {
from_s = new FileInputStream( from);
to_s = to.getOutputStream();
if (buf == null)
buf = new byte[BUFFER_SIZE]; // reuse this buffer to copy files
for (int bytesRead = from_s.read(buf);
bytesRead != -1;
bytesRead = from_s.read(buf))
to_s.write(buf,0,bytesRead);
from_s.close();
from_s = null;
storageFactory.sync( to_s, false); // RESOLVE: sync or no sync?
to_s.close();
to_s = null;
}
catch (IOException ioe)
{
return false;
}
finally
{
if (from_s != null)
{
try { from_s.close(); }
catch (IOException ioe) {}
}
if (to_s != null)
{
try { to_s.close(); }
catch (IOException ioe) {}
}
}
return true;
} // end of copyFile
public static boolean copyFile( WritableStorageFactory storageFactory,
StorageFile from, StorageFile to)
{
return copyFile( storageFactory, from, to, (byte[]) null);
}
public static boolean copyFile( WritableStorageFactory storageFactory,
StorageFile from, StorageFile to,
byte[] buf)
{
InputStream from_s = null;
OutputStream to_s = null;
try {
from_s = from.getInputStream();
to_s = to.getOutputStream();
if (buf == null)
buf = new byte[BUFFER_SIZE]; // reuse this buffer to copy files
for (int bytesRead = from_s.read(buf);
bytesRead != -1;
bytesRead = from_s.read(buf))
to_s.write(buf,0,bytesRead);
from_s.close();
from_s = null;
storageFactory.sync( to_s, false); // RESOLVE: sync or no sync?
to_s.close();
to_s = null;
}
catch (IOException ioe)
{
return false;
}
finally
{
if (from_s != null)
{
try { from_s.close(); }
catch (IOException ioe) {}
}
if (to_s != null)
{
try { to_s.close(); }
catch (IOException ioe) {}
}
}
return true;
} // end of copyFile
/**
Convert a file path into a File object with an absolute path
relative to a passed in root. If path is absolute then
a file object constructed from new File(path) is returned,
otherwise a file object is returned from new File(root, path)
if root is not null, otherwise null is returned.
*/
public static File getAbsoluteFile(File root, String path) {
File file = new File(path);
if (file.isAbsolute())
return file;
if (root == null)
return null;
return new File(root, path);
}
/**
A replacement for new File(File, String) that correctly implements
the case when the first argument is null. The documentation for java.io.File
says that new File((File) null, name) is the same as new File(name).
This is not the case in pre 1.1.8 vms, a NullPointerException is thrown instead.
*/
public static File newFile(File parent, String name) {
if (parent == null)
return new File(name);
else
return new File(parent, name);
}
/**
Remove the leading 'file://' protocol from a filename which has been
expressed as an URL. If the filename is not an URL, then nothing is done.
Otherwise, an URL like 'file:///tmp/foo.txt' is transformed into the legal
file name '/tmp/foo.txt'.
*/
public static String stripProtocolFromFileName( String originalName )
{
String result = originalName;
try {
URL url = new URL(originalName);
result = url.getFile();
} catch (MalformedURLException ex) {}
return result;
}
// Members used by limitAccessToOwner
private static final Object region = new Object();
private static boolean initialized = false;
// Reflection helper objects for calling into Java >= 6
private static Method setWrite = null;
private static Method setRead = null;
private static Method setExec = null;
// Reflection helper objects for calling into Java >= 7
private static Class fileClz = File.class;
private static Class filesClz;
private static Class pathClz;
private static Class pathsClz;
private static Class aclEntryClz;
private static Class aclFileAttributeViewClz;
private static Class posixFileAttributeViewClz;
private static Class userPrincipalClz;
private static Class linkOptionArrayClz;
private static Class linkOptionClz;
private static Class stringArrayClz;
private static Class aclEntryBuilderClz;
private static Class aclEntryTypeClz;
private static Class fileStoreClz;
private static Class aclEntryPermissionClz;
private static Method get;
private static Method getFileAttributeView;
private static Method supportsFileAttributeView;
private static Method getFileStore;
private static Method getOwner;
private static Method getAcl;
private static Method setAcl;
private static Method principal;
private static Method getName;
private static Method build;
private static Method newBuilder;
private static Method setPrincipal;
private static Method setType;
private static Method values;
private static Method setPermissions;
private static Field allow;
/**
* Use when creating new files. If running with Java 6 or higher on Unix,
* limit read and write permissions on {@code file} to owner if {@code
* derby.storage.useDefaultFilePermissions == false}.
* <p/>
* If the property is not specified, we use restrictive permissions anyway
* iff running with the server server started from the command line.
* <p/>
* On Unix, this is equivalent to running with umask 0077.
* <p/>
* On Windows, with FAT/FAT32, we lose, since the fs does not support
* permissions, only a read-only flag.
* <p/>
* On Windows, with NTFS with ACLs, if running with Java 7 or higher, we
* limit access also for Windows using the new {@code
* java.nio.file.attribute} package.
*
* @param file assumed to be just created
*/
public static void limitAccessToOwner(File file) {
String value = PropertyUtil.getSystemProperty(
Property.STORAGE_USE_DEFAULT_FILE_PERMISSIONS);
if (value != null) {
if (Boolean.valueOf(value.trim()).booleanValue()) {
return;
}
} else {
// The property has not been specified. Only proceed if we are
// running with the network server started from the command line
// *and* at Java 7 or above
if (JVMInfo.JDK_ID >= JVMInfo.J2SE_17 &&
(PropertyUtil.getSystemBoolean(
Property.SERVER_STARTED_FROM_CMD_LINE, false)) ) {
// proceed
} else {
return;
}
}
// lazy initialization, needs to be called in security context
synchronized (region) {
if (!initialized) {
initialized = true;
// >= Java 6
try {
setWrite = fileClz.getMethod(
"setWritable",
new Class[]{Boolean.TYPE, Boolean.TYPE});
setRead = fileClz.getMethod(
"setReadable",
new Class[]{Boolean.TYPE, Boolean.TYPE});
setExec = fileClz.getMethod(
"setExecutable",
new Class[]{Boolean.TYPE, Boolean.TYPE});
} catch (NoSuchMethodException e) {
// not Java 6 or higher
}
// >= Java 7
try {
// If found, we have >= Java 7.
filesClz = Class.forName(
"java.nio.file.Files");
pathClz = Class.forName(
"java.nio.file.Path");
pathsClz = Class.forName(
"java.nio.file.Paths");
aclEntryClz = Class.forName(
"java.nio.file.attribute.AclEntry");
aclFileAttributeViewClz = Class.forName(
"java.nio.file.attribute.AclFileAttributeView");
posixFileAttributeViewClz = Class.forName(
"java.nio.file.attribute.PosixFileAttributeView");
userPrincipalClz = Class.forName(
"java.nio.file.attribute.UserPrincipal");
linkOptionArrayClz = Class.forName(
"[Ljava.nio.file.LinkOption;");
linkOptionClz = Class.forName(
"java.nio.file.LinkOption");
stringArrayClz = Class.forName(
"[Ljava.lang.String;");
aclEntryBuilderClz = Class.forName(
"java.nio.file.attribute.AclEntry$Builder");
aclEntryTypeClz = Class.forName(
"java.nio.file.attribute.AclEntryType");
fileStoreClz = Class.forName(
"java.nio.file.FileStore");
aclEntryPermissionClz = Class.forName(
"java.nio.file.attribute.AclEntryPermission");
get = pathsClz.getMethod(
"get",
new Class[]{String.class, stringArrayClz});
getFileAttributeView = filesClz.getMethod(
"getFileAttributeView",
new Class[]{pathClz, Class.class, linkOptionArrayClz});
supportsFileAttributeView = fileStoreClz.getMethod(
"supportsFileAttributeView",
new Class[]{Class.class});
getFileStore = filesClz.getMethod("getFileStore",
new Class[]{pathClz});
getOwner = filesClz.
getMethod("getOwner",
new Class[]{pathClz, linkOptionArrayClz});
getAcl = aclFileAttributeViewClz.
getMethod("getAcl", new Class[]{});
setAcl = aclFileAttributeViewClz.
getMethod("setAcl", new Class[]{List.class});
principal = aclEntryClz.
getMethod("principal", new Class[]{});
getName = userPrincipalClz.
getMethod("getName", new Class[]{});
build = aclEntryBuilderClz.
getMethod("build", new Class[]{});
newBuilder = aclEntryClz.
getMethod("newBuilder", new Class[]{});
setPrincipal = aclEntryBuilderClz.
getMethod("setPrincipal",
new Class[]{userPrincipalClz});
setType = aclEntryBuilderClz.
getMethod("setType", new Class[]{aclEntryTypeClz});
values = aclEntryPermissionClz.
getMethod("values", (Class[]) null);
setPermissions = aclEntryBuilderClz.
getMethod("setPermissions", new Class[] { Set.class });
allow = aclEntryTypeClz.getField("ALLOW");
} catch (NoSuchMethodException e) {
// not Java 7 or higher
} catch (ClassNotFoundException e) {
// not Java 7 or higher
} catch (NoSuchFieldException e) {
// not Java 7 or higher
}
}
}
if (setWrite == null) {
// JVM level too low
return;
}
if (limitAccessToOwnerViaACLs(file)) {
return;
}
try {
//
// First switch off all write access
//
Object r;
r = setWrite.invoke(
file,
new Object[]{Boolean.FALSE, Boolean.FALSE});
assertTrue(r);
//
// Next, switch on write again, but for owner only
//
r = setWrite.invoke(
file,
new Object[]{Boolean.TRUE, Boolean.TRUE});
assertTrue(r);
//
// First switch off all read access
//
r = setRead.invoke(
file,
new Object[]{Boolean.FALSE, Boolean.FALSE});
assertTrue(r);
//
// Next, switch on read access again, but for owner only
//
r = setRead.invoke(
file,
new Object[]{Boolean.TRUE, Boolean.TRUE});
assertTrue(r);
if (file.isDirectory()) {
//
// First switch off all exec access
//
r = setExec.invoke(
file,
new Object[]{Boolean.FALSE, Boolean.FALSE});
assertTrue(r);
//
// Next, switch on read exec again, but for owner only
//
r = setExec.invoke(
file,
new Object[]{Boolean.TRUE, Boolean.TRUE});
assertTrue(r);
}
} catch (InvocationTargetException e) {
// setWritable/setReadable can throw SecurityException
throw (SecurityException)e.getCause();
} catch (IllegalAccessException e) {
// coding error
if (SanityManager.DEBUG) {
SanityManager.THROWASSERT(e);
}
}
}
private static void assertTrue(Object r){
// We should always have the permission to modify the access since have
// just created the file. On some file systems, some operations will
// not work, though, notably FAT/FAT32, as well as NTFS on java < 7, so
// we ignore it the failure.
if (SanityManager.DEBUG) {
Boolean b = (Boolean)r;
if (!b.booleanValue()) {
String os =
PropertyUtil.getSystemProperty("os.name").toLowerCase();
if (os.indexOf("windows") >= 0) {
// expect this to fail, Java 6 on Windows doesn't cut it,
// known not to work.
} else {
SanityManager.THROWASSERT(
"File.set{RWX} failed on this file system");
}
}
}
}
private static boolean limitAccessToOwnerViaACLs(File file) {
// See if we are running on JDK 7 so we can deny access
// using the new java.nio.file.attribute package.
if (filesClz == null) {
// nope
return false;
}
// We have Java 7, so call. We need to call reflectively, since the
// source level isn't yet at Java 7.
try {
// Path fileP = Paths.get(file.getPath());
Object fileP = get.invoke(
null, new Object[]{file.getPath(), new String[]{}});
// ACLs supported on this platform, now check the current file
// system:
Object fileStore = getFileStore.invoke(
null,
new Object[]{fileP});
boolean supported =
((Boolean)supportsFileAttributeView.invoke(
fileStore,
new Object[]{aclFileAttributeViewClz})).booleanValue();
if (!supported) {
return false;
}
// AclFileAttributeView view =
// Files.getFileAttributeView(fileP,
// AclFileAttributeView.class);
Object view = getFileAttributeView.invoke(
null,
new Object[]{fileP,
aclFileAttributeViewClz,
Array.newInstance(linkOptionClz, 0)});
if (view == null) {
return false;
}
// If we have a posix view, just return and fall back on
// the JDK 6 approach.
Object posixView = getFileAttributeView.invoke(
null,
new Object[]{fileP,
posixFileAttributeViewClz,
Array.newInstance(linkOptionClz, 0)});
if (posixView != null) {
return false;
}
// Since we have an AclFileAttributeView which is not a
// PosixFileAttributeView, we probably have a NTFS file
// system.
// UserPrincipal owner = Files.getOwner(fileP);
Object owner = getOwner.invoke(
null,
new Object[]{fileP, Array.newInstance(linkOptionClz, 0)});
//
// Remove existing ACEs, build a new one which simply
// gives all possible permissions to current owner.
//
// List<AclEntry> newAcl = new ArrayList<>();
// AclEntryPermissions[] perms = AclEntryPermission.values();
// AclEntry.Builder aceb = AclEntry.newBuilder();
//
// aceb.setType(AclEntryType.ALLOW);
// aceb.setPermissions(new HashSet(Arrays.asList(perms);
// newAcl.add(aceb);
List newAcl = new ArrayList();
Object[] perms = (Object[]) values.invoke(null, (Object[]) null);
Object aceb = newBuilder.invoke(null, (Object[]) null);
Object allowValue = allow.get(aclEntryTypeClz);
aceb = setPrincipal.invoke(aceb, new Object[]{owner});
aceb = setType.invoke(aceb, new Object[]{allowValue});
aceb = setPermissions.invoke(
aceb,
new Object[] {new HashSet(Arrays.asList(perms))});
newAcl.add(build.invoke(aceb, (Object[]) null));
// view.setAcl(newAcl);
setAcl.invoke(view, new Object[]{newAcl});
} catch (IllegalAccessException e) {
// coding error
if (SanityManager.DEBUG) {
SanityManager.THROWASSERT(e);
}
} catch (IllegalArgumentException e) {
// coding error
if (SanityManager.DEBUG) {
SanityManager.THROWASSERT(e);
}
} catch (InvocationTargetException e) {
// java.security.AccessControlException: access denied
// ("java.lang.RuntimePermission" "accessUserInformation") can
// happen, so throw.
//
// Should we get an IOException from getOwner, the cast below
// would throw which is fine, since it should not happen.
throw (RuntimeException)e.getCause();
}
return true;
}
}
|
[
"snjezana@6f3ba3e3-413c-0410-a8aa-90bee3ab43b5"
] |
snjezana@6f3ba3e3-413c-0410-a8aa-90bee3ab43b5
|
6594c8af5ab06747a7224ed9bfdc1e9915bfb2df
|
b9d42da2e746f3acafb9841ee3deb1905b1706d0
|
/app/src/test/java/com/example/chern007/calculadoraprimos/ExampleUnitTest.java
|
dbba83dd9340d65c29a44a61ee09490d1932b393
|
[] |
no_license
|
chern007/calculadoraPrimos
|
95a51cbb42bbed5a6edf210962c2b68cce03f196
|
b9d3871d6775c6b039b8dd698459c6cec6845f2c
|
refs/heads/master
| 2021-07-24T01:54:14.536194
| 2017-11-02T12:01:07
| 2017-11-02T12:01:07
| 108,549,892
| 1
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 416
|
java
|
package com.example.chern007.calculadoraprimos;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
|
[
"carlos.hernandez_crespo@nokia"
] |
carlos.hernandez_crespo@nokia
|
07c818828d4ce2347fae3c1cd92c5fbbc28bdf12
|
8bd339799bc8427a23c2cdd2e61a2c17dd19f842
|
/yuu-rpcframework-project/yuu-rpcframework-core/src/main/java/com/yuu/registry/registryanddiscovery/zk/util/CuratorUtils.java
|
04b8b8bad11b349da7596b6c28746708875e88c0
|
[] |
no_license
|
zhangshuyuz/yuu-rpcframework
|
5ef712bdd3dac37373de7ae2c6c8ce6e8c617830
|
cea493f4be81b45b9356916bb929f2d998f6a818
|
refs/heads/master
| 2023-06-19T18:42:07.826516
| 2021-07-22T11:12:23
| 2021-07-22T11:12:23
| 388,431,860
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 6,067
|
java
|
package com.yuu.registry.registryanddiscovery.zk.util;
import com.yuu.common.enums.RpcConfigEnum;
import com.yuu.common.utils.PropertiesFileUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.imps.CuratorFrameworkState;
import org.apache.curator.framework.recipes.cache.PathChildrenCache;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.apache.zookeeper.CreateMode;
import java.net.InetSocketAddress;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
@Slf4j
public class CuratorUtils {
private static final int BASE_SLEEP_TIME = 1000;
private static final int MAX_RETRIES = 3;
public static final String ZK_REGISTER_ROOT_PATH = "/my-rpc";
private static final Map<String, List<String>> SERVICE_ADDRESS_MAP = new ConcurrentHashMap<>();
private static final Set<String> REGISTERED_PATH_SET = ConcurrentHashMap.newKeySet();
private static CuratorFramework zkClient;
private static final String DEFAULT_ZOOKEEPER_ADDRESS = "127.0.0.1:2181";
private CuratorUtils() {
}
/**
* Create persistent nodes. Unlike temporary nodes, persistent nodes are not removed when the client disconnects
*
* @param path node path
*/
public static void createPersistentNode(CuratorFramework zkClient, String path) {
try {
if (REGISTERED_PATH_SET.contains(path) || zkClient.checkExists().forPath(path) != null) {
log.info("The node already exists. The node is:[{}]", path);
} else {
//eg: /my-rpc/github.javaguide.HelloService/127.0.0.1:9999
zkClient.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(path);
log.info("The node was created successfully. The node is:[{}]", path);
}
REGISTERED_PATH_SET.add(path);
} catch (Exception e) {
log.error("create persistent node for path [{}] fail", path);
}
}
/**
* Gets the children under a node
*
* @param rpcServiceName rpc service name eg:github.javaguide.HelloServicetest2version1
* @return All child nodes under the specified node
*/
public static List<String> getChildrenNodes(CuratorFramework zkClient, String rpcServiceName) {
if (SERVICE_ADDRESS_MAP.containsKey(rpcServiceName)) {
return SERVICE_ADDRESS_MAP.get(rpcServiceName);
}
List<String> result = null;
String servicePath = ZK_REGISTER_ROOT_PATH + "/" + rpcServiceName;
try {
result = zkClient.getChildren().forPath(servicePath);
SERVICE_ADDRESS_MAP.put(rpcServiceName, result);
registerWatcher(rpcServiceName, zkClient);
} catch (Exception e) {
log.error("get children nodes for path [{}] fail", servicePath);
}
return result;
}
/**
* Empty the registry of data
*/
public static void clearRegistry(CuratorFramework zkClient, InetSocketAddress inetSocketAddress) {
REGISTERED_PATH_SET.stream().parallel().forEach(p -> {
try {
if (p.endsWith(inetSocketAddress.toString())) {
zkClient.delete().forPath(p);
}
} catch (Exception e) {
log.error("clear registry for path [{}] fail", p);
}
});
log.info("All registered services on the server are cleared:[{}]", REGISTERED_PATH_SET.toString());
}
public static CuratorFramework getZkClient() {
// check if user has set zk address
Properties properties = PropertiesFileUtil.readPropertiesFile(RpcConfigEnum.RPC_CONFIG_PATH.getPropertyValue());
String zookeeperAddress = properties != null && properties.getProperty(RpcConfigEnum.ZK_ADDRESS.getPropertyValue()) != null ? properties.getProperty(RpcConfigEnum.ZK_ADDRESS.getPropertyValue()) : DEFAULT_ZOOKEEPER_ADDRESS;
// if zkClient has been started, return directly
if (zkClient != null && zkClient.getState() == CuratorFrameworkState.STARTED) {
return zkClient;
}
// Retry strategy. Retry 3 times, and will increase the sleep time between retries.
RetryPolicy retryPolicy = new ExponentialBackoffRetry(BASE_SLEEP_TIME, MAX_RETRIES);
zkClient = CuratorFrameworkFactory.builder()
// the server to connect to (can be a server list)
.connectString(zookeeperAddress)
.retryPolicy(retryPolicy)
.build();
zkClient.start();
try {
// wait 30s until connect to the zookeeper
if (!zkClient.blockUntilConnected(30, TimeUnit.SECONDS)) {
throw new RuntimeException("Time out waiting to connect to ZK!");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
return zkClient;
}
/**
* Registers to listen for changes to the specified node
*
* @param rpcServiceName rpc service name eg:github.javaguide.HelloServicetest2version
*/
private static void registerWatcher(String rpcServiceName, CuratorFramework zkClient) throws Exception {
String servicePath = ZK_REGISTER_ROOT_PATH + "/" + rpcServiceName;
PathChildrenCache pathChildrenCache = new PathChildrenCache(zkClient, servicePath, true);
PathChildrenCacheListener pathChildrenCacheListener = (curatorFramework, pathChildrenCacheEvent) -> {
List<String> serviceAddresses = curatorFramework.getChildren().forPath(servicePath);
SERVICE_ADDRESS_MAP.put(rpcServiceName, serviceAddresses);
};
pathChildrenCache.getListenable().addListener(pathChildrenCacheListener);
pathChildrenCache.start();
}
}
|
[
"2245376379@qq.com"
] |
2245376379@qq.com
|
8967fbb90dcb65466498d84832faf596ecf3774a
|
5bb8ddea6fd25b53071cdc7b41ad0a3cfebd57f8
|
/Learn_Object-Oriented_Java_the_Hard_Way/learn-oo-java-files/SquareRootTester.java
|
f2329b2b119e1cf94f62075773a6f608b6af62c7
|
[] |
no_license
|
josephbrockw/continued_education
|
5c561b5f699226424346330d0396c69b70b5e103
|
34b943a542a98343665bc81ca1bbfd8efa2d9f66
|
refs/heads/master
| 2020-03-29T04:07:44.933937
| 2018-09-29T15:47:43
| 2018-09-29T15:47:43
| 149,516,821
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 686
|
java
|
public class SquareRootTester {
public static void main( String[] args ) {
SquareRootFinder sqrt = new SquareRootFinder();
double max = 0, maxN = 0;
double fakeroot, realroot, diff;
System.out.print("Testing square root algorithm... ");
for ( double n = 0; n<=2000; n += 0.01 ) {
sqrt.setNumber(n);
fakeroot = sqrt.getRoot();
realroot = Math.sqrt(n);
diff = Math.abs( fakeroot - realroot );
if ( diff > max ) {
max = diff;
maxN = n;
}
}
if ( max > 0.000001 ) {
System.out.println("FAIL");
System.out.println("Worst difference was " + max + " for " + maxN );
}
else
System.out.println("PASS");
}
}
|
[
"me@thejoewilkinson.com"
] |
me@thejoewilkinson.com
|
5fa4ae2eff204d403e38e6cd5022b101758ff532
|
ce8361b6742549a94359e6ad204d6299bf40a585
|
/apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/PropertyResolverTest.java
|
65ac928382e27498481e27b6d76874471e7248e8
|
[
"Apache-2.0"
] |
permissive
|
leusonmario/apollo
|
dbdadfdbee40db2152220fa528cbec6708b2df2c
|
ea8406986d717e7100a36aa049ec601f624aa0a9
|
refs/heads/master
| 2021-07-11T11:45:58.950581
| 2016-06-30T06:18:50
| 2016-06-30T06:18:50
| 106,391,141
| 0
| 0
| null | 2017-10-10T08:41:25
| 2017-10-10T08:41:25
| null |
UTF-8
|
Java
| false
| false
| 4,600
|
java
|
package com.ctrip.framework.apollo.portal;
import com.ctrip.framework.apollo.core.dto.ItemChangeSets;
import com.ctrip.framework.apollo.core.dto.ItemDTO;
import com.ctrip.framework.apollo.core.exception.BadRequestException;
import com.ctrip.framework.apollo.portal.service.txtresolver.ConfigTextResolver;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class PropertyResolverTest extends AbstractPortalTest {
@Autowired
private ConfigTextResolver resolver;
@Test
public void testEmptyText() {
try {
resolver.resolve(0, "", null);
} catch (Exception e) {
Assert.assertTrue(e instanceof BadRequestException);
}
}
@Test
public void testAddItemBeforeNoItem() {
ItemChangeSets changeSets = resolver.resolve(1, "a=b\nb=c", Collections.emptyList());
Assert.assertEquals(2, changeSets.getCreateItems().size());
}
@Test
public void testAddItemBeforeHasItem() {
ItemChangeSets changeSets = resolver.resolve(1, "x=y\na=b\nb=c\nc=d", mockBaseItemHas3Key());
Assert.assertEquals("x", changeSets.getCreateItems().get(0).getKey());
Assert.assertEquals(1, changeSets.getCreateItems().size());
Assert.assertEquals(3, changeSets.getUpdateItems().size());
}
@Test
public void testAddCommentAndBlankItem() {
ItemChangeSets changeSets = resolver.resolve(1, "#ddd\na=b\n\nb=c\nc=d", mockBaseItemHas3Key());
Assert.assertEquals(2, changeSets.getCreateItems().size());
Assert.assertEquals(3, changeSets.getUpdateItems().size());
}
@Test
public void testChangeItemNumLine() {
ItemChangeSets changeSets = resolver.resolve(1, "b=c\nc=d\na=b", mockBaseItemHas3Key());
Assert.assertEquals(3, changeSets.getUpdateItems().size());
}
@Test
public void testDeleteItem() {
ItemChangeSets changeSets = resolver.resolve(1, "a=b", mockBaseItemHas3Key());
Assert.assertEquals(2, changeSets.getDeleteItems().size());
}
@Test
public void testDeleteCommentItem() {
ItemChangeSets changeSets = resolver.resolve(1, "a=b\n\nb=c", mockBaseItemWith2Key1Comment1Blank());
Assert.assertEquals(2, changeSets.getDeleteItems().size());
Assert.assertEquals(2, changeSets.getUpdateItems().size());
Assert.assertEquals(1, changeSets.getCreateItems().size());
}
@Test
public void testDeleteBlankItem(){
ItemChangeSets changeSets = resolver.resolve(1, "#qqqq\na=b\nb=c", mockBaseItemWith2Key1Comment1Blank());
Assert.assertEquals(1, changeSets.getDeleteItems().size());
Assert.assertEquals(1, changeSets.getUpdateItems().size());
Assert.assertEquals(0, changeSets.getCreateItems().size());
}
@Test
public void testUpdateItem() {
ItemChangeSets changeSets = resolver.resolve(1, "a=d", mockBaseItemHas3Key());
List<ItemDTO> updateItems = changeSets.getUpdateItems();
Assert.assertEquals(1, updateItems.size());
Assert.assertEquals("d", updateItems.get(0).getValue());
}
@Test
public void testUpdateCommentItem() {
ItemChangeSets changeSets = resolver.resolve(1, "#ww\n"
+ "a=b\n"
+"\n"
+ "b=c", mockBaseItemWith2Key1Comment1Blank());
Assert.assertEquals(1, changeSets.getDeleteItems().size());
Assert.assertEquals(0, changeSets.getUpdateItems().size());
Assert.assertEquals(1, changeSets.getCreateItems().size());
}
@Test
public void testAllSituation(){
ItemChangeSets changeSets = resolver.resolve(1, "#ww\nd=e\nb=c\na=b\n\nq=w\n#eee", mockBaseItemWith2Key1Comment1Blank());
Assert.assertEquals(2, changeSets.getDeleteItems().size());
Assert.assertEquals(2, changeSets.getUpdateItems().size());
Assert.assertEquals(5, changeSets.getCreateItems().size());
}
/**
* a=b b=c c=d
*/
private List<ItemDTO> mockBaseItemHas3Key() {
ItemDTO item1 = new ItemDTO("a", "b", "", 1);
ItemDTO item2 = new ItemDTO("b", "c", "", 2);
ItemDTO item3 = new ItemDTO("c", "d", "", 3);
return Arrays.asList(item1, item2, item3);
}
/**
* #qqqq
* a=b
*
* b=c
*/
private List<ItemDTO> mockBaseItemWith2Key1Comment1Blank() {
ItemDTO i1 = new ItemDTO("", "", "#qqqq", 1);
ItemDTO i2 = new ItemDTO("a", "b", "", 2);
ItemDTO i3 = new ItemDTO("", "", "", 3);
ItemDTO i4 = new ItemDTO("b", "c", "", 4);
i4.setLineNum(4);
return Arrays.asList(i1, i2, i3, i4);
}
}
|
[
"ledou.zhang@dianping.com"
] |
ledou.zhang@dianping.com
|
45ca1650ee62f95c2a53e39eb61fdcde976664b1
|
1e65fd20b52c1b60bab9814ca0016f6063f56567
|
/src/main/java/com/test/shardingsphere/service/TestService.java
|
4e8260199f44e14e957760a39e60bf4be1a036a8
|
[
"Apache-2.0"
] |
permissive
|
cy18cn/orch-sharding-ms
|
b250e6891edb3f3dfd7cb72edd24fd79db84d655
|
f7b45288d0a2026132eecd901595649050933229
|
refs/heads/master
| 2021-07-22T11:01:22.569344
| 2019-12-06T09:55:11
| 2019-12-06T09:55:11
| 223,922,630
| 0
| 1
|
Apache-2.0
| 2020-10-13T17:43:31
| 2019-11-25T10:33:09
|
Java
|
UTF-8
|
Java
| false
| false
| 915
|
java
|
/*
* Copyright © 2019 Airparking HERE <ryan.cao@airparking.cn>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.test.shardingsphere.service;
import com.airparking.cloud.common.AbstractService;
import com.test.shardingsphere.entity.Test;
/**
* Created by ryan on 2019-04-04 17:32:45.
*/
public interface TestService extends AbstractService<Test, Long> {
Integer add(Test object);
}
|
[
"ryan.cao@airparking.cn"
] |
ryan.cao@airparking.cn
|
f8ace09ad332875feb4c43da4ab93a521e30cba9
|
8116e2b93b079a703ed2cd5315e4c5989e896569
|
/module4/10_session_cookie/exercises/b03_add_product_to_cart/src/main/java/com/example/b03_add_product_to_cart/B03AddProductToCartApplication.java
|
56c9ff945366247b4145d8947e8c0ee4989a1e36
|
[] |
no_license
|
PhanGiaKhanh/C0221G1-CodeGym.
|
657e451e21d2c43d9b4018cc617c5eb5c94a8f4c
|
d28288850f4ace937146df2d556a40bdf71ada7a
|
refs/heads/main
| 2023-08-19T20:02:22.677147
| 2021-09-29T09:52:26
| 2021-09-29T09:52:26
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 366
|
java
|
package com.example.b03_add_product_to_cart;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class B03AddProductToCartApplication {
public static void main(String[] args) {
SpringApplication.run(B03AddProductToCartApplication.class, args);
}
}
|
[
"phangiakhanh90@gmail.com"
] |
phangiakhanh90@gmail.com
|
1305d58ebc2d590446f320a6cd222838d30e7257
|
b5d69ac40421c94fb07511d544242bf4a4ff0246
|
/src/main/java/com/hibernate/crud/operations/idao/ITeacherDAO.java
|
bf605bde90c73f4a22f8a50c2ab3cbe956aa26ef
|
[] |
no_license
|
MaksimYudin/TimeControl_SpringBootVersion
|
598de6bcc02f0e9f7eac3c2808c59b800cb06c23
|
974dacf515dbb52978b6b71cff32e7425975e02e
|
refs/heads/master
| 2022-07-09T09:25:04.626057
| 2019-12-27T13:46:06
| 2019-12-27T13:46:06
| 230,450,829
| 0
| 0
| null | 2022-02-10T01:33:55
| 2019-12-27T13:42:34
|
Java
|
UTF-8
|
Java
| false
| false
| 316
|
java
|
package com.hibernate.crud.operations.idao;
import org.russianfeature.model.Teacher;
import java.util.List;
import java.util.Map;
public interface ITeacherDAO extends IGenericDAO<Teacher, Integer> {
Teacher findByName(String name, String surname);
List<Teacher> getDoubles(Map<String, String> params);
}
|
[
"metalman@inbox.ru"
] |
metalman@inbox.ru
|
0f685163cc47c6e465f157feab924aa1b50f2ad0
|
ee2e56b3a4ea4cedf51ed04cd5928c73f1140fb0
|
/java/shop/src/gen-old/java/de/epages/ws/orderdocument4/model/TGetInvoices_Return.java
|
4fb3733175eff0439dba9458fb9ed775ee16e8c1
|
[
"Apache-2.0"
] |
permissive
|
ePages-de/soapclient
|
75efbd786e8c74d42fa24f9d56b29e79a347d444
|
bbcb74b38bdf6629266bbb3d0fe1a19dee4b58b8
|
refs/heads/dev
| 2023-07-12T05:35:53.333154
| 2023-06-23T08:10:21
| 2023-06-23T08:10:21
| 14,296,539
| 2
| 18
| null | 2023-06-23T08:10:23
| 2013-11-11T09:28:51
|
Java
|
UTF-8
|
Java
| false
| false
| 6,728
|
java
|
/**
* TGetInvoices_Return.java
*
* This file was auto-generated from WSDL
* by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
*/
package de.epages.ws.orderdocument4.model;
/**
* a single return value of a getInvoices() call.
* The Order will be always returned.
* The error element will be returned in case of error.
* The Invoices element will be returned if no error occured.
*/
public class TGetInvoices_Return implements java.io.Serializable {
private java.lang.String order;
/* paths of all invoices of the order */
private java.lang.String[] invoices;
/* error object (see epagestypes:TError) */
private de.epages.ws.common.model.TError error;
public TGetInvoices_Return() {
}
public TGetInvoices_Return(
java.lang.String order,
java.lang.String[] invoices,
de.epages.ws.common.model.TError error) {
this.order = order;
this.invoices = invoices;
this.error = error;
}
/**
* Gets the order value for this TGetInvoices_Return.
*
* @return order
*/
public java.lang.String getOrder() {
return order;
}
/**
* Sets the order value for this TGetInvoices_Return.
*
* @param order
*/
public void setOrder(java.lang.String order) {
this.order = order;
}
/**
* Gets the invoices value for this TGetInvoices_Return.
*
* @return invoices * paths of all invoices of the order
*/
public java.lang.String[] getInvoices() {
return invoices;
}
/**
* Sets the invoices value for this TGetInvoices_Return.
*
* @param invoices * paths of all invoices of the order
*/
public void setInvoices(java.lang.String[] invoices) {
this.invoices = invoices;
}
/**
* Gets the error value for this TGetInvoices_Return.
*
* @return error * error object (see epagestypes:TError)
*/
public de.epages.ws.common.model.TError getError() {
return error;
}
/**
* Sets the error value for this TGetInvoices_Return.
*
* @param error * error object (see epagestypes:TError)
*/
public void setError(de.epages.ws.common.model.TError error) {
this.error = error;
}
private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof TGetInvoices_Return)) return false;
TGetInvoices_Return other = (TGetInvoices_Return) obj;
if (obj == null) return false;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsCalc == obj);
}
__equalsCalc = obj;
boolean _equals;
_equals = true &&
((this.order==null && other.getOrder()==null) ||
(this.order!=null &&
this.order.equals(other.getOrder()))) &&
((this.invoices==null && other.getInvoices()==null) ||
(this.invoices!=null &&
java.util.Arrays.equals(this.invoices, other.getInvoices()))) &&
((this.error==null && other.getError()==null) ||
(this.error!=null &&
this.error.equals(other.getError())));
__equalsCalc = null;
return _equals;
}
private boolean __hashCodeCalc = false;
public synchronized int hashCode() {
if (__hashCodeCalc) {
return 0;
}
__hashCodeCalc = true;
int _hashCode = 1;
if (getOrder() != null) {
_hashCode += getOrder().hashCode();
}
if (getInvoices() != null) {
for (int i=0;
i<java.lang.reflect.Array.getLength(getInvoices());
i++) {
java.lang.Object obj = java.lang.reflect.Array.get(getInvoices(), i);
if (obj != null &&
!obj.getClass().isArray()) {
_hashCode += obj.hashCode();
}
}
}
if (getError() != null) {
_hashCode += getError().hashCode();
}
__hashCodeCalc = false;
return _hashCode;
}
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(TGetInvoices_Return.class, true);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("urn://epages.de/WebService/OrderDocumentTypes/2008/05", "TGetInvoices_Return"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("order");
elemField.setXmlName(new javax.xml.namespace.QName("", "Order"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("invoices");
elemField.setXmlName(new javax.xml.namespace.QName("", "Invoices"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("error");
elemField.setXmlName(new javax.xml.namespace.QName("", "Error"));
elemField.setXmlType(new javax.xml.namespace.QName("urn://epages.de/WebService/EpagesTypes/2005/01", "TError"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
}
/**
* Return type metadata object
*/
public static org.apache.axis.description.TypeDesc getTypeDesc() {
return typeDesc;
}
/**
* Get Custom Serializer
*/
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
}
/**
* Get Custom Deserializer
*/
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanDeserializer(
_javaType, _xmlType, typeDesc);
}
}
|
[
"otrosien@epages.com"
] |
otrosien@epages.com
|
248b5c4a6be7fb87d5bdfbee37d6b2e70c21dd48
|
056334778e609dcfdcaafccdf977b75b8d83d589
|
/basico/src/com/vetor/VetoresW.java
|
017e25d4c3f25b0c2a6cc226c91d58f64864660f
|
[] |
no_license
|
gilbertogi/aula1-github
|
c5196a5dfa03df18d5a416ec048e296511440b6d
|
424d2679bd51d5cbeacf897c518952eb3f8975a2
|
refs/heads/master
| 2020-06-14T14:27:16.147566
| 2019-07-03T10:09:20
| 2019-07-03T10:09:20
| 195,026,430
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,026
|
java
|
package com.vetor;
import java.util.Scanner;
public class VetoresW {
public static void main (String [] args) {
Scanner scan = new Scanner (System.in);
String nome="";
int idade=0;
double salario=0;
String sexo="";
String estadoCivil="";
boolean valida =false;
while(valida==false) {
System.out.println("Entre com o nome de usuario");
nome=scan.next();
if(nome.length()>3) {
valida=true;
}else {
System.out.println("O nome deve ter mais de 3 caractres, digite novamente");
}
}
valida =false;
while(valida==false) {
System.out.println("Entre com a idade");
idade=scan.nextInt();
if(idade>=0 && idade<=150) {
valida=true;
}else {
System.out.println("Idade deve estar entre 0 a 150, digite novamente");
}
}
valida =false;
while(valida==false) {
System.out.println("Entre com o salario");
salario=scan.nextDouble();
if(salario>0) {
valida=true;
}else {
System.out.println("O salario deve ser difrente de 0, digite novamente");
}
}
valida =false;
while(valida==false) {
System.out.println("Entre com sexo");
sexo=scan.next();
if(sexo.equalsIgnoreCase("f") || sexo.equalsIgnoreCase("m")) {
valida=true;
}else {
System.out.println("Sexo deve M ou F, digite novamente");
}
}
valida =false;
while(valida==false) {
System.out.println("Entre com Estado Civil");
estadoCivil=scan.next();
if(estadoCivil.equalsIgnoreCase("s") || estadoCivil.equalsIgnoreCase("c") || estadoCivil.equalsIgnoreCase("v") || estadoCivil.equalsIgnoreCase("d")) {
valida=true;
}else {
System.out.println("Estado civil s,c,d,v. digite novamente");
}
}
System.out.println(nome);
System.out.println(idade);
System.out.println(salario);
System.out.println(sexo);
System.out.println(estadoCivil);
}
}
|
[
"gilbertogimbi@yahoo.com"
] |
gilbertogimbi@yahoo.com
|
6379c155f2d37db26aa6dfce0f77bfe1a93ddf46
|
ea4f669d92128d32eb71a9473f9f80e4acc43bd9
|
/src/getdata/AppGet.java
|
d24f07196661bb00de39f35f701987911dcac787
|
[] |
no_license
|
lananh1909/oop_group_19
|
77f9657e299871b3b46efb55a716b236381ead66
|
49a88f26ff5087f17feb165c27c237689e30e4e0
|
refs/heads/master
| 2022-10-09T13:00:51.146280
| 2020-06-11T14:57:11
| 2020-06-11T14:57:11
| 263,094,526
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 465
|
java
|
package getdata;
import java.io.IOException;
public class AppGet {
public static void main(String[] args) {
try {
new GetDataHNX("HNX", "data//10062020//HNX-1006.txt").getData();
new GetDataHNX("HNX30", "data//10062020//HNX30-1006.txt").getData();
new GetDataHOSE("HOSE", "data//10062020//HOSE-1006.txt").getData();
new GetDataHOSE("VN30", "data//10062020//VN30-1006.txt").getData();
} catch (IOException e) {
e.printStackTrace();
}
}
}
|
[
"lananha1k17@gmail.com"
] |
lananha1k17@gmail.com
|
b253d3a14f150a84e241d8d7c7626bcc068d6268
|
1e6d00fb0b454ccf690e571a0bfda456c21329f7
|
/src/main/java/com/reimia/xmlResolve2/ICommand.java
|
125b9c70d8b09b6bf8f346f09ec4622e1dd7a256
|
[] |
no_license
|
Reimia/mdzz
|
b24bcc6c072aacf964674a14d3bad6bb97d37bf4
|
9932235b2719ee073e327e0d15f813c5a18e6630
|
refs/heads/master
| 2022-06-30T10:59:52.848579
| 2021-04-20T02:57:27
| 2021-04-20T02:57:27
| 216,738,268
| 0
| 0
| null | 2022-06-17T02:47:09
| 2019-10-22T06:23:51
|
Java
|
UTF-8
|
Java
| false
| false
| 857
|
java
|
package com.reimia.xmlResolve2;
import com.reimia.convert.IDevice;
/**
* @author cwang
*/
public interface ICommand {
/**
* 获取上下文 ID,这个 ID 一般用来在异步交互中进行数据匹配
*
* @return
*/
String getContextID();
/**
* 设置上下文 ID,这个 ID 一般用来在异步交互中进行数据匹配
*/
void setContextID(String contextID);
/**
* 获取命令所属设备
*
* @return
*/
IDevice getDevice();
/**
* 设置命令是否已被处理标识
*
* @param b
*/
void setIsProcessed(boolean b);
/**
* 获取命令是否已被处理标识
*
* @return
*/
boolean getIsProcessed();
/**
* 设置命令处理结果代码
*
* @param code
*/
void setProcessCode(String code);
/**
* 获取命令处理结果代码
*
* @return
*/
String getProcessCode();
}
|
[
"zhangsiyu@zjft.com"
] |
zhangsiyu@zjft.com
|
74330e3b8db782885d6fc082bb4231985990e6d0
|
97bc205956012589e099a5b36ccc75a0f1c08046
|
/src/main/java/team/ruike/imm/entity/EventDetails.java
|
743d85f4daa111ae6e8af218cee0a929ea6da255
|
[] |
no_license
|
baron2050/IMM
|
c6e7112db479e95f4d9862c54750afd4bb358670
|
a5d20e2c803d7faf674806baca9678cdb24e688e
|
refs/heads/master
| 2020-06-19T23:20:43.504260
| 2017-11-24T05:58:23
| 2017-11-24T05:58:23
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 955
|
java
|
package team.ruike.imm.entity;
/**
* @author 索志文
* @versrion 2.0
* 活动详情
*/
public class EventDetails {
/**
* 活动编号
*/
private Integer eventDetailsId;
/**
* 活动详情
*/
private String eventDetailsName;
/**
* 是否已删除
*/
private Integer eventDetailsState;
public Integer getEventDetailsState() {
return eventDetailsState;
}
public void setEventDetailsState(Integer eventDetailsState) {
this.eventDetailsState = eventDetailsState;
}
public Integer getEventDetailsId() {
return eventDetailsId;
}
public void setEventDetailsId(Integer eventDetailsId) {
this.eventDetailsId = eventDetailsId;
}
public String getEventDetailsName() {
return eventDetailsName;
}
public void setEventDetailsName(String eventDetailsName) {
this.eventDetailsName = eventDetailsName;
}
}
|
[
"1050320769@qq.com"
] |
1050320769@qq.com
|
a059de5b6126b053a66d35b9032cdd80102572ff
|
245684b5207087050130e0e7c50949a08a699bed
|
/PhoneBook/src/SQLiteModel.java
|
bf25f19e3a1d14979c4d2b068a33487cb0dc35c9
|
[] |
no_license
|
Brothre23/Software-Engineering-HW1
|
5ff98f1f785531633664ac6e9b6823823444b2ba
|
cde6f09617e715c5e878a5f02287c1e66fd18643
|
refs/heads/master
| 2020-04-09T16:58:56.254487
| 2018-12-05T05:51:28
| 2018-12-05T05:51:28
| 160,467,735
| 3
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,725
|
java
|
import java.io.IOException;
import java.sql.*;
import java.util.Enumeration;
import java.util.Hashtable;
public class SQLiteModel extends PhoneBookModel {
public SQLiteModel(PhoneBookView view) throws IOException{
phonebookview = view;
phoneBook = new Hashtable();
try{
Connection database = DriverManager.getConnection("jdbc:sqlite:SQLdatabase.db");
// database中不存在table的話則新增table
DatabaseMetaData md = database.getMetaData();
ResultSet rs = md.getTables(null, null, "PHONEBOOK", null);
Statement stmt = database.createStatement();
if (!rs.next()){
stmt.executeUpdate("CREATE TABLE PHONEBOOK(NAME TEXT, PHONE TEXT);");
}
// 從table中取出資料
rs = stmt.executeQuery("SELECT * FROM PHONEBOOK");
while (rs.next()){
String name = rs.getString("NAME");
String phone = rs.getString("PHONE");
phoneBook.put(name, phone);
}
rs.close();
// stmt.close();
database.close();
} catch (Exception e){
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
}
public void updateDB() throws Exception{
Enumeration names = phoneBook.keys();
String name, phone, sql;
try{
Connection database = DriverManager.getConnection("jdbc:sqlite:SQLdatabase.db");
Statement stmt = database.createStatement();
// 因為介面配合關係,TXT和SQL的model在更新時都是把檔案清空再重新寫入,
// 而SQLite沒有TRUNCATE指令,所以使用DROP把整個table刪除再新增
sql = "DROP TABLE PHONEBOOK";
stmt.executeUpdate(sql);
sql = "CREATE TABLE PHONEBOOK" +
"(NAME TEXT, PHONE TEXT);";
stmt.executeUpdate(sql);
// 從hash table中取出資料寫入資料庫
while (names.hasMoreElements()){
name = (String) names.nextElement();
phone = phoneBook.get(name);
name = "'" + name + "'";
phone = "'" + phone + "'";
sql = "INSERT INTO PHONEBOOK (NAME,PHONE)" + "VALUES (" + name + ", " + phone + ");";
stmt.executeUpdate(sql);
}
stmt.close();
database.close();
} catch (Exception e){
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
}
}
|
[
"noreply@github.com"
] |
Brothre23.noreply@github.com
|
e60ce8ba0a1201ecbb9ceb21f9aa121e24be0471
|
fb6d45e32e8bebc850d95a7013223dd3de10c15f
|
/RockMobile/src/org/church/rockmobile/SeriesFragment.java
|
17de854336d4771523d0c3bd7bbcc63447032de8
|
[] |
no_license
|
skysoftkgs/RockMobile-Android
|
0877b4d60bbae48c4e6836ff5a1dd6be3d9b8a03
|
73d7a475297f50d9c15ee5bceb10e80f596e6e56
|
refs/heads/master
| 2020-07-09T04:06:38.228399
| 2019-08-22T21:06:02
| 2019-08-22T21:06:02
| 203,871,356
| 1
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 3,946
|
java
|
package org.church.rockmobile;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.church.rockmobile.adapter.SeriesListAdapter;
import org.church.rockmobile.common.Constants;
import org.church.rockmobile.common.AppManager;
import org.church.rockmobile.model.SeriesModel;
import org.church.rockmobile.model.UserModel;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.ProgressBar;
import com.flurry.android.FlurryAgent;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener2;
import com.handmark.pulltorefresh.library.PullToRefreshGridView;
import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseQuery;
public class SeriesFragment extends BaseFragment{
MainActivity mActivity;
boolean mIsSeriesLoading;
PullToRefreshGridView mPullRefreshSeriesGridView;
GridView mSeriesGridView;
ProgressBar mProgressBar;
SeriesListAdapter mAdapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_series, container, false);
mActivity = (MainActivity) getActivity();
mPullRefreshSeriesGridView = (PullToRefreshGridView) rootView.findViewById(R.id.gridView_series);
mSeriesGridView = mPullRefreshSeriesGridView.getRefreshableView();
mPullRefreshSeriesGridView.setOnRefreshListener(new OnRefreshListener2<GridView>() {
@Override
public void onPullDownToRefresh(PullToRefreshBase<GridView> refreshView) {
loadSeries();
}
@Override
public void onPullUpToRefresh(PullToRefreshBase<GridView> refreshView) {
mPullRefreshSeriesGridView.onRefreshComplete();
}
});
mProgressBar = (ProgressBar) rootView.findViewById(R.id.progressBar_series);
showSeries();
//track event
Map<String, String> params = new HashMap<String, String>();
params.put("username", UserModel.getCurrentUser().getUsername());
FlurryAgent.logEvent("Series", params);
return rootView;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// TODO Auto-generated method stub
super.onCreateOptionsMenu(menu, inflater);
initActionBar();
}
public void initActionBar(){
//customize actionbar
LayoutInflater inflator = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflator.inflate(R.layout.actionbar_series, null);
mActivity.mActionBar.setCustomView(v);
}
public void showSeries(){
if(AppManager.mSeriesList.size() <= 0)
loadSeries();
else{
if(mAdapter == null)
mAdapter = new SeriesListAdapter(mActivity, AppManager.mSeriesList);
mSeriesGridView.setAdapter(mAdapter);
mProgressBar.setVisibility(View.GONE);
}
}
public void loadSeries(){
if(mIsSeriesLoading) return;
mIsSeriesLoading = true;
if(!mPullRefreshSeriesGridView.isRefreshing())
mProgressBar.setVisibility(View.VISIBLE);
ParseQuery<SeriesModel> query = new ParseQuery<SeriesModel>("Series");
query.whereEqualTo("churchId", Constants.CHURCH_ID);
query.orderByDescending("startDate");
query.findInBackground(new FindCallback<SeriesModel>() {
@Override
public void done(List<SeriesModel> list, ParseException err) {
// TODO Auto-generated method stub
if(list != null){
AppManager.mSeriesList = list;
mAdapter = new SeriesListAdapter(mActivity, list);
mSeriesGridView.setAdapter(mAdapter);
}
mIsSeriesLoading = false;
mProgressBar.setVisibility(View.GONE);
mPullRefreshSeriesGridView.onRefreshComplete();
}
});
}
}
|
[
"archen97@gmail.com"
] |
archen97@gmail.com
|
bd7e9ebe73a5eef4726cc8a38f5c279b43fa3748
|
ee520a34cdcd59b746843f97b65a0faf15ec94ea
|
/src/regstudent.java
|
f390729c7fae95152d14552b8742fba241e71fe3
|
[] |
no_license
|
ShrabantiRimi/student_moderating_system
|
371f9666a8257ede304ecbedaa2e612a79ef51ad
|
b65aa8a32654025c776b715cf932720762bcb30d
|
refs/heads/master
| 2020-05-04T20:50:16.947555
| 2019-04-04T08:20:09
| 2019-04-04T08:20:09
| 179,452,950
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 34,907
|
java
|
import java.sql.*;
import javax.swing.*;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class regstudent extends javax.swing.JFrame {
public regstudent() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
studentname = new javax.swing.JLabel();
av = new javax.swing.JLabel();
fo = new javax.swing.JLabel();
preadd = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
studentmother = new javax.swing.JLabel();
dateofbirth = new javax.swing.JLabel();
sscgpa = new javax.swing.JLabel();
hsc = new javax.swing.JLabel();
hscgpa = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
se = new javax.swing.JLabel();
gpn = new javax.swing.JLabel();
fai = new javax.swing.JLabel();
mo = new javax.swing.JLabel();
mai = new javax.swing.JLabel();
lc = new javax.swing.JLabel();
stuname = new javax.swing.JTextField();
stufather = new javax.swing.JTextField();
stumother = new javax.swing.JTextField();
gpassc = new javax.swing.JTextField();
hscc = new javax.swing.JTextField();
gpahsc = new javax.swing.JTextField();
localg = new javax.swing.JTextField();
dateofb = new javax.swing.JTextField();
ssc = new javax.swing.JTextField();
gpnt = new javax.swing.JTextField();
ste = new javax.swing.JTextField();
adn = new javax.swing.JTextField();
validation = new javax.swing.JButton();
studentid = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
exit = new javax.swing.JButton();
fao = new javax.swing.JTextField();
faani = new javax.swing.JTextField();
paddt = new javax.swing.JTextField();
padd2 = new javax.swing.JPasswordField();
mao = new javax.swing.JTextField();
ids = new javax.swing.JTextField();
pass = new javax.swing.JTextField();
padd = new javax.swing.JLabel();
maai = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText(" REGISTRATION");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(156, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(193, 193, 193))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 27, Short.MAX_VALUE)
.addGap(36, 36, 36))
);
studentname.setText("Student Name");
av.setText("Advisor name");
fo.setText("Father occupation");
preadd.setText("present Address");
jLabel10.setText("S.S.C(School name)");
studentmother.setText("Student Father Name");
dateofbirth.setText("Date of Birth");
sscgpa.setText("S.S.C(GPA)");
hsc.setText("H.S.C(College name)");
hscgpa.setText("H.S.C(GPA)");
jLabel18.setText("Student Mother Name");
se.setText("Student Email");
gpn.setText("Guardien phone number");
fai.setText("Father Annual Income");
mo.setText("Mother occupation");
mai.setText("Mother Annual Income");
lc.setText("Local Guardien");
ssc.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sscActionPerformed(evt);
}
});
validation.setText("Validation");
validation.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
validationActionPerformed(evt);
}
});
studentid.setText("student id");
jLabel3.setText("student password");
exit.setText("submit");
exit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
exitActionPerformed(evt);
}
});
padd.setText("permanent Address");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGap(61, 61, 61)
.addComponent(validation, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(150, 150, 150)
.addComponent(exit, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(210, 210, 210)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(stuname, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
.addComponent(stufather, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(stumother, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(dateofb, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(ssc, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(gpassc, javax.swing.GroupLayout.Alignment.TRAILING))
.addGap(50, 50, 50)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(padd, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(fao, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(preadd, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(faani, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(fai, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(adn)
.addComponent(ste)
.addComponent(maai)))
.addGroup(layout.createSequentialGroup()
.addComponent(fo, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(mao, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(studentid, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(90, 90, 90)
.addComponent(paddt, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(lc, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(90, 90, 90)
.addComponent(localg, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(hscgpa, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(74, 74, 74)
.addComponent(gpahsc, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(studentname, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(dateofbirth, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sscgpa, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(studentmother, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(hscc, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(hsc, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(153, 153, 153)))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(gpn, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(gpnt, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(padd2, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(37, 37, 37)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(mai, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(mo, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(se, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(ids, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(av, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pass, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(283, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(studentname)
.addComponent(stuname, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(studentmother)
.addComponent(stufather, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(stumother, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(preadd))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(dateofbirth)
.addComponent(dateofb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(ssc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(gpassc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(sscgpa, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33))
.addGroup(layout.createSequentialGroup()
.addGap(6, 6, 6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(padd)
.addComponent(fao, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addComponent(faani, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(fo)
.addComponent(mao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(54, 54, 54)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(hscc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(hsc)
.addComponent(fai)
.addComponent(maai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(29, 29, 29)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(hscgpa)
.addComponent(gpahsc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(mo)
.addComponent(ste, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(1, 1, 1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(gpn, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(gpnt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(se)
.addComponent(ids, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGap(26, 26, 26)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lc)
.addComponent(localg, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(mai, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(adn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(52, 52, 52)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(studentid, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(paddt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(av, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(padd2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(40, 40, 40)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(validation)
.addComponent(exit))
.addGap(305, 305, 305))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void sscActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sscActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_sscActionPerformed
private void validationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_validationActionPerformed
close();
validation og=new validation ();
og.setVisible(true);
}//GEN-LAST:event_validationActionPerformed
public void close()
{
this.setVisible(false);
this.dispose();
}
private void exitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitActionPerformed
String Student_Name =stuname.getText().toString();
String Student_Father_Name =stufather.getText().toString();
String Student_Mother_Name =stumother.getText().toString();
String Date_of_Birth =dateofb.getText().toString();
String SSC_Schoolname =ssc.getText().toString();
String ssc_gpa =gpassc.getText().toString();
String hsc_collegeName =hscc.getText().toString();
String hsc_gpa =gpahsc.getText().toString();
String Local_Guardien =localg.getText().toString();
String Guardien_phone_number =gpnt.getText().toString();
String student_id =paddt.getText().toString();
String student_password =padd2.getText().toString();
String permanent_Address =fao.getText().toString();
String present_Address =faani.getText().toString();
String Father_occupation =mao.getText().toString();
String Father_Annual_Income =maai.getText().toString();
String Mother_occupation =ste.getText().toString();
String Mother_Annual_Income =adn.getText().toString();
String Student_Email =ids.getText().toString();
String Advisor_name =pass.getText().toString();
if(Student_Name.equals(""))
{
JOptionPane.showMessageDialog(null,"Student_Name is Mandatory");
}
if(Student_Father_Name.equals(""))
{
JOptionPane.showMessageDialog(null,"Student_Father_Name is Mandatory");
}
if(Student_Mother_Name.equals(""))
{
JOptionPane.showMessageDialog(null,"Student_Mother_Name is Mandatory");
}
if(Date_of_Birth.equals(""))
{
JOptionPane.showMessageDialog(null,"Date_of_Birth is Mandatory");
}
if(SSC_Schoolname.equals(""))
{
JOptionPane.showMessageDialog(null,"SSC_Schoolname is Mandatory");
}
if(ssc_gpa.equals(""))
{
JOptionPane.showMessageDialog(null,"ssc_gpa is Mandatory");
}
if(hsc_collegeName.equals(""))
{
JOptionPane.showMessageDialog(null,"hsc_collegeName is Mandatory");
}
if(hsc_gpa.equals(""))
{
JOptionPane.showMessageDialog(null,"hsc_gpa is Mandatory");
}
if(Local_Guardien.equals(""))
{
JOptionPane.showMessageDialog(null,"Local_Guardien is Mandatory");
}
if(Guardien_phone_number.equals(""))
{
JOptionPane.showMessageDialog(null,"Guardien_phone_number is Mandatory");
}
if(student_id.equals(""))
{
JOptionPane.showMessageDialog(null,"student_id is Mandatory");
}
if(student_password.equals(""))
{
JOptionPane.showMessageDialog(null,"student_password is Mandatory");
}
if(permanent_Address.equals(""))
{
JOptionPane.showMessageDialog(null,"permanent_Address is Mandatory");
}
if(present_Address.equals(""))
{
JOptionPane.showMessageDialog(null,"present_Address is Mandatory");
}
if(Father_occupation.equals(""))
{
JOptionPane.showMessageDialog(null,"Father_occupation is Mandatory");
}
if(Father_Annual_Income.equals(""))
{
JOptionPane.showMessageDialog(null,"Father_Annual_Income is Mandatory");
}
if(Mother_occupation.equals(""))
{
JOptionPane.showMessageDialog(null,"Mother_occupation is Mandatory");
}
if(Mother_Annual_Income.equals(""))
{
JOptionPane.showMessageDialog(null,"Mother_Annual_Income is Mandatory");
}
if(Student_Email.equals(""))
{
JOptionPane.showMessageDialog(null,"Student_Email is Mandatory");
}
if(Advisor_name.equals(""))
{
JOptionPane.showMessageDialog(null,"Advisor_name is Mandatory");
}
JOptionPane.showMessageDialog(null,"enter data successfull");
try{
String url="jdbc:derby://localhost:1527/studentM";
String username="admin3";
String password="admin3";
Connection con =DriverManager.getConnection(url,username, password);
Statement stmt=con.createStatement();
String Query="INSERT INTO STUDENTREG(STUDENT_NAME,STUDENT_FATHER_NAME,STUDENT_MOTHER_NAME,SSC_SCHOOLNAME,HSC_COLLEGENAME,LOCAL_GUARDIAN,GUARDIAN_PHONENUM,PERMANENT_ADDRESS,PRESENT_ADDRESS,FATHER_OCCUPATION,MOTHER_OCCUPATION,ADVISOR,STUDENT_PASSWORD,SSC_GPA,HSC_GPA,MOTHER_ANNUAL_INCOME,FATHER_ANNUAL_INCOME,DATE_OF_BATH,STUDENT_ID,STUDENT_EMAIL)VALUES('"+stuname.getText()+"' ,'"
+stufather.getText()+ "' , '"+stumother.getText()+"' , '" +ssc.getText() +"','"+hscc.getText() +"' , '"+localg.getText()+"', '"+gpnt.getText()+"', '"+fao.getText()+"','"+faani.getText()+"','"+mao.getText()+"','"+ste.getText()+"','"+pass.getText()+"','"+padd2.getText()+"','"+gpassc.getText()+"','"+gpahsc.getText() +"','"+adn.getText()+"','"+maai.getText()+"','"+dateofb.getText()+"','"+paddt.getText()+"','"+ids.getText()+"')";
String Query1="INSERT INTO NEWTRY(LOCAL_GUARDIAN,GUARDIAN_PHONENUM,STUDENT_PASSWORD)VALUES('"+localg.getText()+"' ,'"
+gpnt.getText()+ "' , '"+padd2.getText()+"' )";
stmt.execute(Query);
stmt.execute(Query1);
JOptionPane.showMessageDialog(null,"Student Information added ");
JOptionPane.showMessageDialog(null,"Guardian phone "+gpnt.getText());
JOptionPane.showMessageDialog(null,"Guardian password "+padd2.getText());
stuname.setText(null);
stufather.setText(null);
stumother.setText(null);
ssc.setText(null);
hscc.setText(null);
localg.setText(null);
gpnt.setText(null);
fao.setText(null);
faani.setText(null);
mao.setText(null);
ste.setText(null);
pass.setText(null);
padd2.setText(null);
gpassc.setText(null);
gpahsc.setText(null);
adn.setText(null);
maai.setText(null);
dateofb.setText(null);
paddt.setText(null);
ids.setText(null);
}//GEN-LAST:event_exitActionPerformed
catch(SQLException ex)
{
JOptionPane.showMessageDialog(null,ex.toString());
}
}
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(regstudent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(regstudent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(regstudent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(regstudent.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new regstudent().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField adn;
private javax.swing.JLabel av;
private javax.swing.JTextField dateofb;
private javax.swing.JLabel dateofbirth;
private javax.swing.JButton exit;
private javax.swing.JTextField faani;
private javax.swing.JLabel fai;
private javax.swing.JTextField fao;
private javax.swing.JLabel fo;
private javax.swing.JTextField gpahsc;
private javax.swing.JTextField gpassc;
private javax.swing.JLabel gpn;
private javax.swing.JTextField gpnt;
private javax.swing.JLabel hsc;
private javax.swing.JTextField hscc;
private javax.swing.JLabel hscgpa;
private javax.swing.JTextField ids;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lc;
private javax.swing.JTextField localg;
private javax.swing.JTextField maai;
private javax.swing.JLabel mai;
private javax.swing.JTextField mao;
private javax.swing.JLabel mo;
private javax.swing.JLabel padd;
private javax.swing.JPasswordField padd2;
private javax.swing.JTextField paddt;
private javax.swing.JTextField pass;
private javax.swing.JLabel preadd;
private javax.swing.JLabel se;
private javax.swing.JTextField ssc;
private javax.swing.JLabel sscgpa;
private javax.swing.JTextField ste;
private javax.swing.JLabel studentid;
private javax.swing.JLabel studentmother;
private javax.swing.JLabel studentname;
private javax.swing.JTextField stufather;
private javax.swing.JTextField stumother;
private javax.swing.JTextField stuname;
private javax.swing.JButton validation;
// End of variables declaration//GEN-END:variables
}
|
[
"RimiPc@DESKTOP-HV8ORFT"
] |
RimiPc@DESKTOP-HV8ORFT
|
fc7ddcaba7b6503e50710cb3fd2ea0ccd9840e39
|
efc9e3c400100c1bdbca92033e488937fb750fda
|
/3.JavaMultithreading/src/com/javarush/task/task29/task2913/Solution.java
|
c59906634f7ec437c35b1385674c215f85161be6
|
[] |
no_license
|
Nikbstar/JavaRushTasks
|
289ffea7798df2c1f22a0335f1e8760f66dac973
|
9b86b284a7f4390807a16e1474e2d58a2be79de0
|
refs/heads/master
| 2018-10-21T03:02:45.724753
| 2018-08-31T06:48:34
| 2018-08-31T06:48:34
| 118,357,131
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 871
|
java
|
package com.javarush.task.task29.task2913;
import java.util.Random;
/*
Замена рекурсии
*/
public class Solution {
private static int numberA;
private static int numberB;
public static String getAllNumbersBetween(int a, int b) {
String result = "";
if (a > b) {
for (int i = a; i >= b; i--) {
result += i + " ";
}
} else {
for (int i = a; i <= b; i++) {
result += i + " ";
}
}
return result.trim();
}
public static void main(String[] args) {
Random random = new Random();
numberA = random.nextInt() % 1_000;
numberB = random.nextInt() % 10_000;
System.out.println(getAllNumbersBetween(numberA, numberB));
System.out.println(getAllNumbersBetween(numberB, numberA));
}
}
|
[
"nikbstar@gmail.com"
] |
nikbstar@gmail.com
|
c3da4c7996376f7b72fc730e4eb2be6acd73bd60
|
53970e56478bbfd6f3cc308841696639e3e24518
|
/src/com/saraiva/Main.java
|
149acc651c17baa623d732a80aa6eed5c55a0943
|
[] |
no_license
|
dsaraiva/mietium-crpt
|
51172cfbb1b53b707adfb5edc6b114b54617e117
|
d81923d096d9e9c7a08639fb4970e453b4a406a5
|
refs/heads/master
| 2021-01-15T18:04:23.386421
| 2015-12-17T11:32:00
| 2015-12-17T11:32:00
| 42,727,412
| 0
| 0
| null | 2015-10-16T14:58:30
| 2015-09-18T14:32:04
|
Java
|
UTF-8
|
Java
| false
| false
| 5,102
|
java
|
package com.saraiva;
import javax.crypto.*;
import javax.crypto.spec.SecretKeySpec;
import java.io.*;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
public class Main {
public static void main(String[] args) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException {
// 1a versao:
// SecureRandom random = new SecureRandom();
// byte[] key_bytes = new byte[16]; //(128bits para RC4)
// random.nextBytes(key_bytes);
// SecretKey key = new SecretKeySpec(key_bytes,"RC4");
SecretKey key;
Cipher c = Cipher.getInstance("RC4");
if(args.length < 1 || args.length> 4){
System.out.println("****** ERRO ******");
help();
System.exit(1);
}
switch (args[0]){
case "-genkey":
generateKey(args[1]);
break;
case "-enc":
key = readKey(args[1]);
c.init(Cipher.ENCRYPT_MODE, key);
encrypt(args[2],args[3],c);
break;
case "-dec":
key = readKey(args[1]);
c.init(Cipher.DECRYPT_MODE, key);
decrypt(args[2], args[3], c);
break;
default:
System.out.println("Argumento invalido!");
help();
break;
}
}
private static void help(){
System.out.println("Modo de utilização:");
System.out.print(
"prog -genkey <keyfile>\n"+
"prog -enc <keyfile> <infile> <outfile>\n"+
"prog -dec <keyfile> <infile> <outfile>\n"
);
}
private static void generateKey(String keyPath) {
File key_file = new File(keyPath);
try {
KeyGenerator kg = KeyGenerator.getInstance("RC4");
kg.init(128);
SecretKey key = kg.generateKey();
byte[] key_bytes = key.getEncoded();
FileOutputStream out = new FileOutputStream(key_file);
out.write(key_bytes);
out.flush();
out.close();
System.out.println("Chave criada com sucesso!");
System.exit(0);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.exit(1);
}
private static SecretKey readKey(String keyfile) {
try {
FileInputStream fis = new FileInputStream(new File(keyfile));
//int n_bytes = fis.available();
//byte [] key_bytes = new byte[n_bytes];
// Como determinar o tamanho da chave? (para funcionar com AES etc)
byte[] key_bytes = new byte[16];
fis.read(key_bytes);
SecretKey key = new SecretKeySpec(key_bytes, "RC4");
return key;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
private static void encrypt(String infile, String outfile, Cipher cipher) {
try {
FileInputStream fis = new FileInputStream(new File(infile));
FileOutputStream fos = new FileOutputStream(new File(outfile));
CipherOutputStream cos = new CipherOutputStream(fos, cipher);
int n;
byte[] data = new byte[1024]; // le 1024 bytes de cada vez -> menos acessos a disco -> mais rapido!
while ((n = fis.read(data, 0, data.length)) != -1) {
cos.write(data, 0, n);
cos.flush();
}
cos.close();
fis.close();
fos.close();
System.out.println("Ficheiro "+infile+" encriptado com sucesso!");
System.exit(0);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.exit(1);
}
private static void decrypt(String infile, String outfile, Cipher cipher){
try {
FileInputStream fis = new FileInputStream(new File(infile));
CipherInputStream cis = new CipherInputStream(fis,cipher);
FileOutputStream fos = new FileOutputStream(new File(outfile));
int n;
byte[] data = new byte[1024];
while( (n=cis.read(data, 0, data.length)) !=-1){
fos.write(data,0,n);
fos.flush();
}
cis.close();
fis.close();
fos.close();
System.out.println("Ficheiro '"+infile+"' desencriptado com sucesso para '"+outfile+"'.");
System.exit(0);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.exit(1);
}
}
|
[
"saraiva.racing@gmail.com"
] |
saraiva.racing@gmail.com
|
41385702f2cb84706577ef19359badfb6cdc335b
|
1ad91fbcd36e6e440aa1c2da375082c8dee0dcd6
|
/src/test/java/stepDifinitions/LoginPageSteps.java
|
5e9bd01151af81582efb79dc1b19231250d1c73b
|
[] |
no_license
|
nguyenthithuy8497/CUCUMBER_MAVEN_THUYNT
|
5ec3c4fd69cff2313903d0e6b8a35f4b14dd1f42
|
4f5e1358019056edaf57bdf75d4935cf39d66401
|
refs/heads/master
| 2020-05-03T13:53:52.694619
| 2019-04-04T04:55:56
| 2019-04-04T04:55:56
| 178,663,666
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,164
|
java
|
package stepDifinitions;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.testng.Assert;
import CucumberOptions.Hooks;
import PageObjects.LoginPageObject;
import PageObjects.PageFactoryManager;
import cucumber.api.DataTable;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import io.github.bonigarcia.wdm.WebDriverManager;
public class LoginPageSteps {
private WebDriver driver;
private LoginPageObject loginPage;
public LoginPageSteps() {
//Map driver
driver = Hooks.openAndQuitBrowser();
//khoi tao doi tuong cho class LoginPageObject
loginPage = PageFactoryManager.getLoginPage(driver);
}
@Given("^I get Login page Url$")
public void iGetLoginPageUrl() {
ShareData.LOGIN_PAGE_URL = loginPage.getLoginPageUrl();
// loginPageUrl = driver.getCurrentUrl();
}
@Given("^I click to here link$")
public void iClickToHereLink() {
loginPage.clickToHereLink();
// driver.findElement(By.xpath("//a[text()='here']")).click();
}
@Given("^Input to Username textbox$")
public void inputToUsernameTextbox() {
loginPage.inputToUserIDTextbox(ShareData.USER_ID);
// driver.findElement(By.xpath("//input[@name='uid']")).sendKeys(userID);
}
@Given("^I input to Password textbox$")
public void iInputToPasswordTextbox() {
loginPage.inputToPasswordTextbox(ShareData.PASSWORD);
// driver.findElement(By.xpath("//input[@name='password']")).sendKeys(password);
}
@Given("^I click to Login button at Login page$")
public void iClickToLoginButtonAtLoginPage() {
loginPage.clickToLoginButton();
// driver.findElement(By.xpath("//input[@name='btnLogin']")).click();
}
public int randomValue() {
Random random = new Random();
return random.nextInt(9999);
}
}
|
[
"nguyenthithuy8497@gmail.com"
] |
nguyenthithuy8497@gmail.com
|
fbeaae402f5dccf6fcc02c5ad7f654115dace993
|
b935d4cf3cc9259a11f2f2102a952da882776fc7
|
/springboot-upload/src/main/java/com/wei/springboot/upload/utils/FileInfoProperties.java
|
87a7ef632f71ee7c3423905e06175c00f82bd44f
|
[] |
no_license
|
meiyuan1633/springboot-demo
|
d9b7dd2e0e78371ec795b9a58cef926a900ef62a
|
0d0badfc8abece725c936616a52319e3b5764a24
|
refs/heads/master
| 2023-03-06T22:48:26.350466
| 2019-12-09T05:52:24
| 2019-12-09T05:52:24
| 226,795,001
| 1
| 0
| null | 2023-02-22T07:38:15
| 2019-12-09T05:52:02
|
Java
|
UTF-8
|
Java
| false
| false
| 399
|
java
|
package com.wei.springboot.upload.utils;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties("fileupload")
@Data
public class FileInfoProperties {
private String rootPath;
private String imagePath;
private String pdfPath;
private String prefixImg;
}
|
[
"1633670876@qq.com"
] |
1633670876@qq.com
|
61e0b69acad7f1278f85eb5ffc83925dc138e368
|
02b2a4833406476155b322a39767208d2f5aa1de
|
/src/main/java/com/interview/test/sfl/restourant/model/ProductInOrder.java
|
39c4f57852d745ca072bc7648d725ecab501bdfe
|
[] |
no_license
|
Nerses83/restourant-sfl
|
1c18832cba3c309f90a64b232ee4dc779e4244e0
|
a6d50da23dc0530c7114926666d172bb4b59bd33
|
refs/heads/master
| 2020-03-07T18:34:43.016917
| 2018-04-02T04:51:05
| 2018-04-02T04:51:05
| 127,644,148
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,866
|
java
|
package com.interview.test.sfl.restourant.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.interview.test.sfl.restourant.model.converter.OrderStatusConverter;
import com.interview.test.sfl.restourant.model.enums.OrderStatus;
import javax.persistence.*;
@Entity
@Table(name = "PRODUCT_IN_TABLE")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class ProductInOrder {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
Long id;
@Column(name = "status")
@Convert(converter = OrderStatusConverter.class)
OrderStatus status;
@ManyToOne
@JoinColumn(name = "order_id")
@JsonIgnore
Order order;
@ManyToOne
@JoinColumn(name = "product_id")
Product product;
Integer count;
public ProductInOrder() {
}
public ProductInOrder(OrderStatus status, Order order, Product product, Integer count) {
this.status = status;
this.order = order;
this.product = product;
this.count = count;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public OrderStatus getStatus() {
return status;
}
public void setStatus(OrderStatus status) {
this.status = status;
}
public Order getOrder() {
return order;
}
public void setOrder(Order order) {
this.order = order;
}
public Product getProduct() {
return product;
}
public void setProduct(Product product) {
this.product = product;
}
}
|
[
"remark07"
] |
remark07
|
462b414fbb68579678698657b36f62eeb6304005
|
2cd40418f8462dccc4c0fb2afe8631e8b61e79b2
|
/app/src/main/java/com/firestudio/projectwordfinding/modals/Word.java
|
f8bbf51f50811a2a5cc2df144f9728bc5d1de5bb
|
[] |
no_license
|
manish25pro/project-word-finding
|
6ae6696d1ea5574e06a9597e1a0ecd2f9f43d151
|
2b0ae2a71c69b8f5c8f40a8e0fb9b7f3915b6eb1
|
refs/heads/master
| 2023-05-28T17:33:38.297500
| 2021-06-17T14:21:31
| 2021-06-17T14:21:31
| 377,856,206
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 599
|
java
|
package com.firestudio.projectwordfinding.modals;
import java.util.List;
public class Word {
private String word;
private Integer score;
private List<String> tags = null;
public String getWord() {
return word;
}
public void setWord(String word) {
this.word = word;
}
public Integer getScore() {
return score;
}
public void setScore(Integer score) {
this.score = score;
}
public List<String> getTags() {
return tags;
}
public void setTags(List<String> tags) {
this.tags = tags;
}
}
|
[
"manishsingal88@gmail.com"
] |
manishsingal88@gmail.com
|
8610f82f70471f8b5092a44789a3568058dd1749
|
bc8d97308cb8baecfacbceacf123f629bd2f3ec4
|
/AndyDemo/src/main/java/com/andy/demo/analysis/bean/MyIdInitResult.java
|
511188ebfea5587150dff8cb6c4682bd6a63d396
|
[] |
no_license
|
Chanven/IDroid
|
9dcdbc47f3e2d248e53810dc3ec48873df356628
|
4f6ee52d72bf16d3c01729a5b79e9436d7b5f1a7
|
refs/heads/master
| 2021-01-21T23:34:06.634764
| 2019-03-06T08:19:52
| 2019-03-06T08:19:52
| 14,129,534
| 1
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 163
|
java
|
package com.andy.demo.analysis.bean;
public class MyIdInitResult {
public String appId;
public String seqId;
public String random;
public String qrCodeUrl;
}
|
[
"chanven0127@gmail.com"
] |
chanven0127@gmail.com
|
95bf5c75774d1dda64a679240edc7f3f1f10f4dd
|
5216a783f27e05a48664197ca1b7a00d41b47397
|
/src/main/java/com/jaguarcode/guestbook/dto/PageRequestDTO.java
|
a8bd81fea6a612ff3569969f68a7b83a3c6357e3
|
[] |
no_license
|
jaguarcode/guestbook-springboot-webservice
|
a376dee132c83a41e92fe1257ac698ff09c967a5
|
a54ec1d585b943f65c2ade91add420ca79d0ccd2
|
refs/heads/master
| 2023-03-24T03:58:01.091726
| 2021-03-19T10:55:10
| 2021-03-19T10:55:10
| 349,282,549
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 562
|
java
|
package com.jaguarcode.guestbook.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
@Builder
@AllArgsConstructor
@Data
public class PageRequestDTO {
private int page;
private int size;
public PageRequestDTO() {
this.page = 1;
this.size = 10;
}
public Pageable getPageable(Sort sort) {
return PageRequest.of(page-1, size, sort);
}
}
|
[
"behonz@gmail.com"
] |
behonz@gmail.com
|
4f1ebeefec169c6e48325ad06920b3c3a8c517c8
|
2783da2050e6ac93265f7e4b695832aa86cf03b9
|
/guns/src/main/java/com/example/tool/util/ImageUtil.java
|
dc576cdf344277eae0454290aeae28d4c9c22c5a
|
[] |
no_license
|
dignjun/FooTest
|
f49f7bf6e4a8e36bb0df4ee8321a826d7dfce580
|
c4f66472ae100bb2ef2b33a44c479cbf6dc5bec4
|
refs/heads/master
| 2022-11-26T22:07:25.921259
| 2020-05-07T15:08:08
| 2020-05-07T15:08:08
| 172,705,687
| 0
| 0
| null | 2022-11-24T03:47:43
| 2019-02-26T12:17:21
|
JavaScript
|
UTF-8
|
Java
| false
| false
| 66,833
|
java
|
package com.example.tool.util;
import com.example.tool.codec.Base64;
import com.example.tool.convert.Convert;
import com.example.tool.exceptions.UtilException;
import com.example.tool.img.Img;
import com.example.tool.io.FileUtil;
import com.example.tool.io.IORuntimeException;
import com.example.tool.io.IoUtil;
import com.example.tool.lang.Assert;
import javax.imageio.*;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.ImageOutputStream;
import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.RenderedImage;
import java.io.*;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
/**
* 图片处理工具类:<br>
* 功能:缩放图像、切割图像、旋转、图像类型转换、彩色转黑白、文字水印、图片水印等 <br>
* 参考:http://blog.csdn.net/zhangzhikaixinya/article/details/8459400
*
* @author DINGJUN
* @date 2019.03.12
*/
public class ImageUtil {
public static final String IMAGE_TYPE_GIF = "gif";// 图形交换格式
public static final String IMAGE_TYPE_JPG = "jpg";// 联合照片专家组
public static final String IMAGE_TYPE_JPEG = "jpeg";// 联合照片专家组
public static final String IMAGE_TYPE_BMP = "bmp";// 英文Bitmap(位图)的简写,它是Windows操作系统中的标准图像文件格式
public static final String IMAGE_TYPE_PNG = "png";// 可移植网络图形
public static final String IMAGE_TYPE_PSD = "psd";// Photoshop的专用格式Photoshop
// ---------------------------------------------------------------------------------------------------------------------- scale
/**
* 缩放图像(按比例缩放)<br>
* 缩放后默认为jpeg格式
*
* @param srcImageFile 源图像文件
* @param destImageFile 缩放后的图像文件
* @param scale 缩放比例。比例大于1时为放大,小于1大于0为缩小
*/
public static void scale(File srcImageFile, File destImageFile, float scale) {
scale(read(srcImageFile), destImageFile, scale);
}
/**
* 缩放图像(按比例缩放)<br>
* 缩放后默认为jpeg格式,此方法并不关闭流
*
* @param srcStream 源图像来源流
* @param destStream 缩放后的图像写出到的流
* @param scale 缩放比例。比例大于1时为放大,小于1大于0为缩小
* @since 3.0.9
*/
public static void scale(InputStream srcStream, OutputStream destStream, float scale) {
scale(read(srcStream), destStream, scale);
}
/**
* 缩放图像(按比例缩放)<br>
* 缩放后默认为jpeg格式,此方法并不关闭流
*
* @param srcStream 源图像来源流
* @param destStream 缩放后的图像写出到的流
* @param scale 缩放比例。比例大于1时为放大,小于1大于0为缩小
* @since 3.1.0
*/
public static void scale(ImageInputStream srcStream, ImageOutputStream destStream, float scale) {
scale(read(srcStream), destStream, scale);
}
/**
* 缩放图像(按比例缩放)<br>
* 缩放后默认为jpeg格式,此方法并不关闭流
*
* @param srcImg 源图像来源流
* @param destFile 缩放后的图像写出到的流
* @param scale 缩放比例。比例大于1时为放大,小于1大于0为缩小
* @throws IORuntimeException IO异常
* @since 3.2.2
*/
public static void scale(Image srcImg, File destFile, float scale) throws IORuntimeException {
write(scale(srcImg, scale), destFile);
}
/**
* 缩放图像(按比例缩放)<br>
* 缩放后默认为jpeg格式,此方法并不关闭流
*
* @param srcImg 源图像来源流
* @param out 缩放后的图像写出到的流
* @param scale 缩放比例。比例大于1时为放大,小于1大于0为缩小
* @throws IORuntimeException IO异常
* @since 3.2.2
*/
public static void scale(Image srcImg, OutputStream out, float scale) throws IORuntimeException {
scale(srcImg, getImageOutputStream(out), scale);
}
/**
* 缩放图像(按比例缩放)<br>
* 缩放后默认为jpeg格式,此方法并不关闭流
*
* @param srcImg 源图像来源流
* @param destImageStream 缩放后的图像写出到的流
* @param scale 缩放比例。比例大于1时为放大,小于1大于0为缩小
* @throws IORuntimeException IO异常
* @since 3.1.0
*/
public static void scale(Image srcImg, ImageOutputStream destImageStream, float scale) throws IORuntimeException {
writeJpg(scale(srcImg, scale), destImageStream);
}
/**
* 缩放图像(按比例缩放)
*
* @param srcImg 源图像来源流
* @param scale 缩放比例。比例大于1时为放大,小于1大于0为缩小
* @return {@link Image}
* @since 3.1.0
*/
public static Image scale(Image srcImg, float scale) {
return Img.from(srcImg).scale(scale).getImg();
}
/**
* 缩放图像(按长宽缩放)<br>
* 注意:目标长宽与原图不成比例会变形
*
* @param srcImg 源图像来源流
* @param width 目标宽度
* @param height 目标高度
* @return {@link Image}
* @since 3.1.0
*/
public static Image scale(Image srcImg, int width, int height) {
return Img.from(srcImg).scale(width, height).getImg();
}
/**
* 缩放图像(按高度和宽度缩放)<br>
* 缩放后默认为jpeg格式
*
* @param srcImageFile 源图像文件地址
* @param destImageFile 缩放后的图像地址
* @param width 缩放后的宽度
* @param height 缩放后的高度
* @param fixedColor 比例不对时补充的颜色,不补充为<code>null</code>
* @throws IORuntimeException IO异常
*/
public static void scale(File srcImageFile, File destImageFile, int width, int height, Color fixedColor) throws IORuntimeException {
write(scale(read(srcImageFile), width, height, fixedColor), destImageFile);
}
/**
* 缩放图像(按高度和宽度缩放)<br>
* 缩放后默认为jpeg格式,此方法并不关闭流
*
* @param srcStream 源图像流
* @param destStream 缩放后的图像目标流
* @param width 缩放后的宽度
* @param height 缩放后的高度
* @param fixedColor 比例不对时补充的颜色,不补充为<code>null</code>
* @throws IORuntimeException IO异常
*/
public static void scale(InputStream srcStream, OutputStream destStream, int width, int height, Color fixedColor) throws IORuntimeException {
scale(read(srcStream), getImageOutputStream(destStream), width, height, fixedColor);
}
/**
* 缩放图像(按高度和宽度缩放)<br>
* 缩放后默认为jpeg格式,此方法并不关闭流
*
* @param srcStream 源图像流
* @param destStream 缩放后的图像目标流
* @param width 缩放后的宽度
* @param height 缩放后的高度
* @param fixedColor 比例不对时补充的颜色,不补充为<code>null</code>
* @throws IORuntimeException IO异常
*/
public static void scale(ImageInputStream srcStream, ImageOutputStream destStream, int width, int height, Color fixedColor) throws IORuntimeException {
scale(read(srcStream), destStream, width, height, fixedColor);
}
/**
* 缩放图像(按高度和宽度缩放)<br>
* 缩放后默认为jpeg格式,此方法并不关闭流
*
* @param srcImage 源图像
* @param destImageStream 缩放后的图像目标流
* @param width 缩放后的宽度
* @param height 缩放后的高度
* @param fixedColor 比例不对时补充的颜色,不补充为<code>null</code>
* @throws IORuntimeException IO异常
*/
public static void scale(Image srcImage, ImageOutputStream destImageStream, int width, int height, Color fixedColor) throws IORuntimeException {
writeJpg(scale(srcImage, width, height, fixedColor), destImageStream);
}
/**
* 缩放图像(按高度和宽度缩放)<br>
* 缩放后默认为jpeg格式
*
* @param srcImage 源图像
* @param width 缩放后的宽度
* @param height 缩放后的高度
* @param fixedColor 比例不对时补充的颜色,不补充为<code>null</code>
* @return {@link Image}
*/
public static Image scale(Image srcImage, int width, int height, Color fixedColor) {
return Img.from(srcImage).scale(width, height, fixedColor).getImg();
}
// ---------------------------------------------------------------------------------------------------------------------- cut
/**
* 图像切割(按指定起点坐标和宽高切割)
*
* @param srcImgFile 源图像文件
* @param destImgFile 切片后的图像文件
* @param rectangle 矩形对象,表示矩形区域的x,y,width,height
* @since 3.1.0
*/
public static void cut(File srcImgFile, File destImgFile, Rectangle rectangle) {
cut(read(srcImgFile), destImgFile, rectangle);
}
/**
* 图像切割(按指定起点坐标和宽高切割),此方法并不关闭流
*
* @param srcStream 源图像流
* @param destStream 切片后的图像输出流
* @param rectangle 矩形对象,表示矩形区域的x,y,width,height
* @since 3.1.0
*/
public static void cut(InputStream srcStream, OutputStream destStream, Rectangle rectangle) {
cut(read(srcStream), destStream, rectangle);
}
/**
* 图像切割(按指定起点坐标和宽高切割),此方法并不关闭流
*
* @param srcStream 源图像流
* @param destStream 切片后的图像输出流
* @param rectangle 矩形对象,表示矩形区域的x,y,width,height
* @since 3.1.0
*/
public static void cut(ImageInputStream srcStream, ImageOutputStream destStream, Rectangle rectangle) {
cut(read(srcStream), destStream, rectangle);
}
/**
* 图像切割(按指定起点坐标和宽高切割),此方法并不关闭流
*
* @param srcImage 源图像
* @param destFile 输出的文件
* @param rectangle 矩形对象,表示矩形区域的x,y,width,height
* @since 3.2.2
* @throws IORuntimeException IO异常
*/
public static void cut(Image srcImage, File destFile, Rectangle rectangle) throws IORuntimeException {
write(cut(srcImage, rectangle), destFile);
}
/**
* 图像切割(按指定起点坐标和宽高切割),此方法并不关闭流
*
* @param srcImage 源图像
* @param out 切片后的图像输出流
* @param rectangle 矩形对象,表示矩形区域的x,y,width,height
* @since 3.1.0
* @throws IORuntimeException IO异常
*/
public static void cut(Image srcImage, OutputStream out, Rectangle rectangle) throws IORuntimeException {
cut(srcImage, getImageOutputStream(out), rectangle);
}
/**
* 图像切割(按指定起点坐标和宽高切割),此方法并不关闭流
*
* @param srcImage 源图像
* @param destImageStream 切片后的图像输出流
* @param rectangle 矩形对象,表示矩形区域的x,y,width,height
* @since 3.1.0
* @throws IORuntimeException IO异常
*/
public static void cut(Image srcImage, ImageOutputStream destImageStream, Rectangle rectangle) throws IORuntimeException {
writeJpg(cut(srcImage, rectangle), destImageStream);
}
/**
* 图像切割(按指定起点坐标和宽高切割)
*
* @param srcImage 源图像
* @param rectangle 矩形对象,表示矩形区域的x,y,width,height
* @return {@link BufferedImage}
* @since 3.1.0
*/
public static BufferedImage cut(Image srcImage, Rectangle rectangle) {
return Img.from(srcImage).setPositionBaseCentre(false).cut(rectangle).getImg();
}
/**
* 图像切割(按指定起点坐标和宽高切割),填充满整个图片(直径取长宽最小值)
*
* @param srcImage 源图像
* @param x 原图的x坐标起始位置
* @param y 原图的y坐标起始位置
* @return {@link BufferedImage}
* @since 4.1.15
*/
public static BufferedImage cut(Image srcImage, int x, int y) {
return cut(srcImage, x, y, -1);
}
/**
* 图像切割(按指定起点坐标和宽高切割)
*
* @param srcImage 源图像
* @param x 原图的x坐标起始位置
* @param y 原图的y坐标起始位置
* @param radius 半径,小于0表示填充满整个图片(直径取长宽最小值)
* @return {@link BufferedImage}
* @since 4.1.15
*/
public static BufferedImage cut(Image srcImage, int x, int y, int radius) {
return Img.from(srcImage).cut(x, y, radius).getImg();
}
/**
* 图像切片(指定切片的宽度和高度)
*
* @param srcImageFile 源图像
* @param descDir 切片目标文件夹
* @param destWidth 目标切片宽度。默认200
* @param destHeight 目标切片高度。默认150
*/
public static void slice(File srcImageFile, File descDir, int destWidth, int destHeight) {
slice(read(srcImageFile), descDir, destWidth, destHeight);
}
/**
* 图像切片(指定切片的宽度和高度)
*
* @param srcImage 源图像
* @param descDir 切片目标文件夹
* @param destWidth 目标切片宽度。默认200
* @param destHeight 目标切片高度。默认150
*/
public static void slice(Image srcImage, File descDir, int destWidth, int destHeight) {
if (destWidth <= 0) {
destWidth = 200; // 切片宽度
}
if (destHeight <= 0) {
destHeight = 150; // 切片高度
}
int srcWidth = srcImage.getHeight(null); // 源图宽度
int srcHeight = srcImage.getWidth(null); // 源图高度
try {
if (srcWidth > destWidth && srcHeight > destHeight) {
int cols = 0; // 切片横向数量
int rows = 0; // 切片纵向数量
// 计算切片的横向和纵向数量
if (srcWidth % destWidth == 0) {
cols = srcWidth / destWidth;
} else {
cols = (int) Math.floor(srcWidth / destWidth) + 1;
}
if (srcHeight % destHeight == 0) {
rows = srcHeight / destHeight;
} else {
rows = (int) Math.floor(srcHeight / destHeight) + 1;
}
// 循环建立切片
BufferedImage tag;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
// 四个参数分别为图像起点坐标和宽高
// 即: CropImageFilter(int x,int y,int width,int height)
tag = cut(srcImage, new Rectangle(j * destWidth, i * destHeight, destWidth, destHeight));
// 输出为文件
ImageIO.write(tag, IMAGE_TYPE_JPEG, new File(descDir, "_r" + i + "_c" + j + ".jpg"));
}
}
}
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
/**
* 图像切割(指定切片的行数和列数)
*
* @param srcImageFile 源图像文件
* @param destDir 切片目标文件夹
* @param rows 目标切片行数。默认2,必须是范围 [1, 20] 之内
* @param cols 目标切片列数。默认2,必须是范围 [1, 20] 之内
*/
public static void sliceByRowsAndCols(File srcImageFile, File destDir, int rows, int cols) {
try {
sliceByRowsAndCols(ImageIO.read(srcImageFile), destDir, rows, cols);
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
/**
* 图像切割(指定切片的行数和列数)
*
* @param srcImage 源图像
* @param destDir 切片目标文件夹
* @param rows 目标切片行数。默认2,必须是范围 [1, 20] 之内
* @param cols 目标切片列数。默认2,必须是范围 [1, 20] 之内
*/
public static void sliceByRowsAndCols(Image srcImage, File destDir, int rows, int cols) {
if (false == destDir.exists()) {
FileUtil.mkdir(destDir);
} else if (false == destDir.isDirectory()) {
throw new IllegalArgumentException("Destination Dir must be a Directory !");
}
try {
if (rows <= 0 || rows > 20) {
rows = 2; // 切片行数
}
if (cols <= 0 || cols > 20) {
cols = 2; // 切片列数
}
// 读取源图像
final BufferedImage bi = toBufferedImage(srcImage);
int srcWidth = bi.getWidth(); // 源图宽度
int srcHeight = bi.getHeight(); // 源图高度
int destWidth = NumberUtil.partValue(srcWidth, cols); // 每张切片的宽度
int destHeight = NumberUtil.partValue(srcHeight, rows); // 每张切片的高度
// 循环建立切片
BufferedImage tag;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
tag = cut(bi, new Rectangle(j * destWidth, i * destHeight, destWidth, destHeight));
// 输出为文件
ImageIO.write(tag, IMAGE_TYPE_JPEG, new File(destDir, "_r" + i + "_c" + j + ".jpg"));
}
}
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
// ---------------------------------------------------------------------------------------------------------------------- convert
/**
* 图像类型转换:GIF=》JPG、GIF=》PNG、PNG=》JPG、PNG=》GIF(X)、BMP=》PNG
*
* @param srcImageFile 源图像文件
* @param destImageFile 目标图像文件
*/
public static void convert(File srcImageFile, File destImageFile) {
Assert.notNull(srcImageFile);
Assert.notNull(destImageFile);
Assert.isFalse(srcImageFile.equals(destImageFile), "Src file is equals to dest file!");
final String srcExtName = FileUtil.extName(srcImageFile);
final String destExtName = FileUtil.extName(destImageFile);
if (StrUtil.equalsIgnoreCase(srcExtName, destExtName)) {
// 扩展名相同直接复制文件
FileUtil.copy(srcImageFile, destImageFile, true);
}
ImageOutputStream imageOutputStream = null;
try {
imageOutputStream = getImageOutputStream(destImageFile);
convert(read(srcImageFile), destExtName, imageOutputStream, StrUtil.equalsIgnoreCase(IMAGE_TYPE_PNG, srcExtName));
} finally {
IoUtil.close(imageOutputStream);
}
}
/**
* 图像类型转换:GIF=》JPG、GIF=》PNG、PNG=》JPG、PNG=》GIF(X)、BMP=》PNG<br>
* 此方法并不关闭流
*
* @param srcStream 源图像流
* @param formatName 包含格式非正式名称的 String:如JPG、JPEG、GIF等
* @param destStream 目标图像输出流
* @since 3.0.9
*/
public static void convert(InputStream srcStream, String formatName, OutputStream destStream) {
write(read(srcStream), formatName, getImageOutputStream(destStream));
}
/**
* 图像类型转换:GIF=》JPG、GIF=》PNG、PNG=》JPG、PNG=》GIF(X)、BMP=》PNG<br>
* 此方法并不关闭流
*
* @param srcStream 源图像流
* @param formatName 包含格式非正式名称的 String:如JPG、JPEG、GIF等
* @param destStream 目标图像输出流
* @since 3.0.9
* @deprecated 请使用{@link #write(Image, String, ImageOutputStream)}
*/
@Deprecated
public static void convert(ImageInputStream srcStream, String formatName, ImageOutputStream destStream) {
write(read(srcStream), formatName, destStream);
}
/**
* 图像类型转换:GIF=》JPG、GIF=》PNG、PNG=》JPG、PNG=》GIF(X)、BMP=》PNG<br>
* 此方法并不关闭流
*
* @param srcImage 源图像流
* @param formatName 包含格式非正式名称的 String:如JPG、JPEG、GIF等
* @param destImageStream 目标图像输出流
* @since 3.0.9
* @deprecated 请使用{@link #write(Image, String, ImageOutputStream)}
*/
@Deprecated
public static void convert(Image srcImage, String formatName, ImageOutputStream destImageStream) {
convert(srcImage, formatName, destImageStream, false);
}
/**
* 图像类型转换:GIF=》JPG、GIF=》PNG、PNG=》JPG、PNG=》GIF(X)、BMP=》PNG<br>
* 此方法并不关闭流
*
* @param srcImage 源图像流
* @param formatName 包含格式非正式名称的 String:如JPG、JPEG、GIF等
* @param destImageStream 目标图像输出流
* @param isSrcPng 源图片是否为PNG格式
* @since 4.1.14
*/
public static void convert(Image srcImage, String formatName, ImageOutputStream destImageStream, boolean isSrcPng) {
try {
ImageIO.write(isSrcPng ? copyImage(srcImage, BufferedImage.TYPE_INT_RGB) : toBufferedImage(srcImage), formatName, destImageStream);
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
// ---------------------------------------------------------------------------------------------------------------------- grey
/**
* 彩色转为黑白
*
* @param srcImageFile 源图像地址
* @param destImageFile 目标图像地址
*/
public static void gray(File srcImageFile, File destImageFile) {
gray(read(srcImageFile), destImageFile);
}
/**
* 彩色转为黑白<br>
* 此方法并不关闭流
*
* @param srcStream 源图像流
* @param destStream 目标图像流
* @since 3.0.9
*/
public static void gray(InputStream srcStream, OutputStream destStream) {
gray(read(srcStream), getImageOutputStream(destStream));
}
/**
* 彩色转为黑白<br>
* 此方法并不关闭流
*
* @param srcStream 源图像流
* @param destStream 目标图像流
* @since 3.0.9
*/
public static void gray(ImageInputStream srcStream, ImageOutputStream destStream) {
gray(read(srcStream), destStream);
}
/**
* 彩色转为黑白
*
* @param srcImage 源图像流
* @param outFile 目标文件
* @since 3.2.2
*/
public static void gray(Image srcImage, File outFile) {
write(gray(srcImage), outFile);
}
/**
* 彩色转为黑白<br>
* 此方法并不关闭流
*
* @param srcImage 源图像流
* @param out 目标图像流
* @since 3.2.2
*/
public static void gray(Image srcImage, OutputStream out) {
gray(srcImage, getImageOutputStream(out));
}
/**
* 彩色转为黑白<br>
* 此方法并不关闭流
*
* @param srcImage 源图像流
* @param destImageStream 目标图像流
* @since 3.0.9
* @throws IORuntimeException IO异常
*/
public static void gray(Image srcImage, ImageOutputStream destImageStream) throws IORuntimeException {
writeJpg(gray(srcImage), destImageStream);
}
/**
* 彩色转为黑白
*
* @param srcImage 源图像流
* @return {@link Image}灰度后的图片
* @since 3.1.0
*/
public static BufferedImage gray(Image srcImage) {
return Img.from(srcImage).gray().getImg();
}
// ---------------------------------------------------------------------------------------------------------------------- binary
/**
* 彩色转为黑白二值化图片,根据目标文件扩展名确定转换后的格式
*
* @param srcImageFile 源图像地址
* @param destImageFile 目标图像地址
*/
public static void binary(File srcImageFile, File destImageFile) {
binary(read(srcImageFile), destImageFile);
}
/**
* 彩色转为黑白二值化图片<br>
* 此方法并不关闭流
*
* @param srcStream 源图像流
* @param destStream 目标图像流
* @param imageType 图片格式(扩展名)
* @since 4.0.5
*/
public static void binary(InputStream srcStream, OutputStream destStream, String imageType) {
binary(read(srcStream), getImageOutputStream(destStream), imageType);
}
/**
* 彩色转为黑白黑白二值化图片<br>
* 此方法并不关闭流
*
* @param srcStream 源图像流
* @param destStream 目标图像流
* @param imageType 图片格式(扩展名)
* @since 4.0.5
*/
public static void binary(ImageInputStream srcStream, ImageOutputStream destStream, String imageType) {
binary(read(srcStream), destStream, imageType);
}
/**
* 彩色转为黑白二值化图片,根据目标文件扩展名确定转换后的格式
*
* @param srcImage 源图像流
* @param outFile 目标文件
* @since 4.0.5
*/
public static void binary(Image srcImage, File outFile) {
write(binary(srcImage), outFile);
}
/**
* 彩色转为黑白二值化图片<br>
* 此方法并不关闭流,输出JPG格式
*
* @param srcImage 源图像流
* @param out 目标图像流
* @param imageType 图片格式(扩展名)
* @since 4.0.5
*/
public static void binary(Image srcImage, OutputStream out, String imageType) {
binary(srcImage, getImageOutputStream(out), imageType);
}
/**
* 彩色转为黑白二值化图片<br>
* 此方法并不关闭流,输出JPG格式
*
* @param srcImage 源图像流
* @param destImageStream 目标图像流
* @param imageType 图片格式(扩展名)
* @since 4.0.5
* @throws IORuntimeException IO异常
*/
public static void binary(Image srcImage, ImageOutputStream destImageStream, String imageType) throws IORuntimeException {
write(binary(srcImage), imageType, destImageStream);
}
/**
* 彩色转为黑白二值化图片
*
* @param srcImage 源图像流
* @return {@link Image}二值化后的图片
* @since 4.0.5
*/
public static BufferedImage binary(Image srcImage) {
return Img.from(srcImage).binary().getImg();
}
// ---------------------------------------------------------------------------------------------------------------------- press
/**
* 给图片添加文字水印
*
* @param imageFile 源图像文件
* @param destFile 目标图像文件
* @param pressText 水印文字
* @param color 水印的字体颜色
* @param font {@link Font} 字体相关信息,如果默认则为{@code null}
* @param x 修正值。 默认在中间,偏移量相对于中间偏移
* @param y 修正值。 默认在中间,偏移量相对于中间偏移
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
*/
public static void pressText(File imageFile, File destFile, String pressText, Color color, Font font, int x, int y, float alpha) {
pressText(read(imageFile), destFile, pressText, color, font, x, y, alpha);
}
/**
* 给图片添加文字水印<br>
* 此方法并不关闭流
*
* @param srcStream 源图像流
* @param destStream 目标图像流
* @param pressText 水印文字
* @param color 水印的字体颜色
* @param font {@link Font} 字体相关信息,如果默认则为{@code null}
* @param x 修正值。 默认在中间,偏移量相对于中间偏移
* @param y 修正值。 默认在中间,偏移量相对于中间偏移
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
*/
public static void pressText(InputStream srcStream, OutputStream destStream, String pressText, Color color, Font font, int x, int y, float alpha) {
pressText(read(srcStream), getImageOutputStream(destStream), pressText, color, font, x, y, alpha);
}
/**
* 给图片添加文字水印<br>
* 此方法并不关闭流
*
* @param srcStream 源图像流
* @param destStream 目标图像流
* @param pressText 水印文字
* @param color 水印的字体颜色
* @param font {@link Font} 字体相关信息,如果默认则为{@code null}
* @param x 修正值。 默认在中间,偏移量相对于中间偏移
* @param y 修正值。 默认在中间,偏移量相对于中间偏移
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
*/
public static void pressText(ImageInputStream srcStream, ImageOutputStream destStream, String pressText, Color color, Font font, int x, int y, float alpha) {
pressText(read(srcStream), destStream, pressText, color, font, x, y, alpha);
}
/**
* 给图片添加文字水印<br>
* 此方法并不关闭流
*
* @param srcImage 源图像
* @param destFile 目标流
* @param pressText 水印文字
* @param color 水印的字体颜色
* @param font {@link Font} 字体相关信息,如果默认则为{@code null}
* @param x 修正值。 默认在中间,偏移量相对于中间偏移
* @param y 修正值。 默认在中间,偏移量相对于中间偏移
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
* @throws IORuntimeException IO异常
* @since 3.2.2
*/
public static void pressText(Image srcImage, File destFile, String pressText, Color color, Font font, int x, int y, float alpha) throws IORuntimeException {
write(pressText(srcImage, pressText, color, font, x, y, alpha), destFile);
}
/**
* 给图片添加文字水印<br>
* 此方法并不关闭流
*
* @param srcImage 源图像
* @param to 目标流
* @param pressText 水印文字
* @param color 水印的字体颜色
* @param font {@link Font} 字体相关信息,如果默认则为{@code null}
* @param x 修正值。 默认在中间,偏移量相对于中间偏移
* @param y 修正值。 默认在中间,偏移量相对于中间偏移
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
* @throws IORuntimeException IO异常
* @since 3.2.2
*/
public static void pressText(Image srcImage, OutputStream to, String pressText, Color color, Font font, int x, int y, float alpha) throws IORuntimeException {
pressText(srcImage, getImageOutputStream(to), pressText, color, font, x, y, alpha);
}
/**
* 给图片添加文字水印<br>
* 此方法并不关闭流
*
* @param srcImage 源图像
* @param destImageStream 目标图像流
* @param pressText 水印文字
* @param color 水印的字体颜色
* @param font {@link Font} 字体相关信息,如果默认则为{@code null}
* @param x 修正值。 默认在中间,偏移量相对于中间偏移
* @param y 修正值。 默认在中间,偏移量相对于中间偏移
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
* @throws IORuntimeException IO异常
*/
public static void pressText(Image srcImage, ImageOutputStream destImageStream, String pressText, Color color, Font font, int x, int y, float alpha) throws IORuntimeException {
writeJpg(pressText(srcImage, pressText, color, font, x, y, alpha), destImageStream);
}
/**
* 给图片添加文字水印<br>
* 此方法并不关闭流
*
* @param srcImage 源图像
* @param pressText 水印文字
* @param color 水印的字体颜色
* @param font {@link Font} 字体相关信息,如果默认则为{@code null}
* @param x 修正值。 默认在中间,偏移量相对于中间偏移
* @param y 修正值。 默认在中间,偏移量相对于中间偏移
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
* @return 处理后的图像
* @since 3.2.2
*/
public static BufferedImage pressText(Image srcImage, String pressText, Color color, Font font, int x, int y, float alpha) {
return Img.from(srcImage).pressText(pressText, color, font, x, y, alpha).getImg();
}
/**
* 给图片添加图片水印
*
* @param srcImageFile 源图像文件
* @param destImageFile 目标图像文件
* @param pressImg 水印图片
* @param x 修正值。 默认在中间,偏移量相对于中间偏移
* @param y 修正值。 默认在中间,偏移量相对于中间偏移
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
*/
public static void pressImage(File srcImageFile, File destImageFile, Image pressImg, int x, int y, float alpha) {
pressImage(read(srcImageFile), destImageFile, pressImg, x, y, alpha);
}
/**
* 给图片添加图片水印<br>
* 此方法并不关闭流
*
* @param srcStream 源图像流
* @param destStream 目标图像流
* @param pressImg 水印图片,可以使用{@link ImageIO#read(File)}方法读取文件
* @param x 修正值。 默认在中间,偏移量相对于中间偏移
* @param y 修正值。 默认在中间,偏移量相对于中间偏移
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
*/
public static void pressImage(InputStream srcStream, OutputStream destStream, Image pressImg, int x, int y, float alpha) {
pressImage(read(srcStream), getImageOutputStream(destStream), pressImg, x, y, alpha);
}
/**
* 给图片添加图片水印<br>
* 此方法并不关闭流
*
* @param srcStream 源图像流
* @param destStream 目标图像流
* @param pressImg 水印图片,可以使用{@link ImageIO#read(File)}方法读取文件
* @param x 修正值。 默认在中间,偏移量相对于中间偏移
* @param y 修正值。 默认在中间,偏移量相对于中间偏移
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
* @throws IORuntimeException IO异常
*/
public static void pressImage(ImageInputStream srcStream, ImageOutputStream destStream, Image pressImg, int x, int y, float alpha) throws IORuntimeException {
pressImage(read(srcStream), destStream, pressImg, x, y, alpha);
}
/**
* 给图片添加图片水印<br>
* 此方法并不关闭流
*
* @param srcImage 源图像流
* @param outFile 写出文件
* @param pressImg 水印图片,可以使用{@link ImageIO#read(File)}方法读取文件
* @param x 修正值。 默认在中间,偏移量相对于中间偏移
* @param y 修正值。 默认在中间,偏移量相对于中间偏移
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
* @throws IORuntimeException IO异常
* @since 3.2.2
*/
public static void pressImage(Image srcImage, File outFile, Image pressImg, int x, int y, float alpha) throws IORuntimeException {
write(pressImage(srcImage, pressImg, x, y, alpha), outFile);
}
/**
* 给图片添加图片水印<br>
* 此方法并不关闭流
*
* @param srcImage 源图像流
* @param out 目标图像流
* @param pressImg 水印图片,可以使用{@link ImageIO#read(File)}方法读取文件
* @param x 修正值。 默认在中间,偏移量相对于中间偏移
* @param y 修正值。 默认在中间,偏移量相对于中间偏移
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
* @throws IORuntimeException IO异常
* @since 3.2.2
*/
public static void pressImage(Image srcImage, OutputStream out, Image pressImg, int x, int y, float alpha) throws IORuntimeException {
pressImage(srcImage, getImageOutputStream(out), pressImg, x, y, alpha);
}
/**
* 给图片添加图片水印<br>
* 此方法并不关闭流
*
* @param srcImage 源图像流
* @param destImageStream 目标图像流
* @param pressImg 水印图片,可以使用{@link ImageIO#read(File)}方法读取文件
* @param x 修正值。 默认在中间,偏移量相对于中间偏移
* @param y 修正值。 默认在中间,偏移量相对于中间偏移
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
* @throws IORuntimeException IO异常
*/
public static void pressImage(Image srcImage, ImageOutputStream destImageStream, Image pressImg, int x, int y, float alpha) throws IORuntimeException {
writeJpg(pressImage(srcImage, pressImg, x, y, alpha), destImageStream);
}
/**
* 给图片添加图片水印<br>
* 此方法并不关闭流
*
* @param srcImage 源图像流
* @param pressImg 水印图片,可以使用{@link ImageIO#read(File)}方法读取文件
* @param x 修正值。 默认在中间,偏移量相对于中间偏移
* @param y 修正值。 默认在中间,偏移量相对于中间偏移
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
* @return 结果图片
*/
public static BufferedImage pressImage(Image srcImage, Image pressImg, int x, int y, float alpha) {
return Img.from(srcImage).pressImage(pressImg, x, y, alpha).getImg();
}
/**
* 给图片添加图片水印<br>
* 此方法并不关闭流
*
* @param srcImage 源图像流
* @param pressImg 水印图片,可以使用{@link ImageIO#read(File)}方法读取文件
* @param rectangle 矩形对象,表示矩形区域的x,y,width,height,x,y从背景图片中心计算
* @param alpha 透明度:alpha 必须是范围 [0.0, 1.0] 之内(包含边界值)的一个浮点数字
* @return 结果图片
* @since 4.1.14
*/
public static BufferedImage pressImage(Image srcImage, Image pressImg, Rectangle rectangle, float alpha) {
return Img.from(srcImage).pressImage(pressImg, rectangle, alpha).getImg();
}
// ---------------------------------------------------------------------------------------------------------------------- rotate
/**
* 旋转图片为指定角度<br>
* 此方法不会关闭输出流
*
* @param imageFile 被旋转图像文件
* @param degree 旋转角度
* @param outFile 输出文件
* @since 3.2.2
* @throws IORuntimeException IO异常
*/
public static void rotate(File imageFile, int degree, File outFile) throws IORuntimeException {
rotate(read(imageFile), degree, outFile);
}
/**
* 旋转图片为指定角度<br>
* 此方法不会关闭输出流
*
* @param image 目标图像
* @param degree 旋转角度
* @param outFile 输出文件
* @since 3.2.2
* @throws IORuntimeException IO异常
*/
public static void rotate(Image image, int degree, File outFile) throws IORuntimeException {
write(rotate(image, degree), outFile);
}
/**
* 旋转图片为指定角度<br>
* 此方法不会关闭输出流
*
* @param image 目标图像
* @param degree 旋转角度
* @param out 输出流
* @since 3.2.2
* @throws IORuntimeException IO异常
*/
public static void rotate(Image image, int degree, OutputStream out) throws IORuntimeException {
writeJpg(rotate(image, degree), getImageOutputStream(out));
}
/**
* 旋转图片为指定角度<br>
* 此方法不会关闭输出流,输出格式为JPG
*
* @param image 目标图像
* @param degree 旋转角度
* @param out 输出图像流
* @since 3.2.2
* @throws IORuntimeException IO异常
*/
public static void rotate(Image image, int degree, ImageOutputStream out) throws IORuntimeException {
writeJpg(rotate(image, degree), out);
}
/**
* 旋转图片为指定角度<br>
* 来自:http://blog.51cto.com/cping1982/130066
*
* @param image 目标图像
* @param degree 旋转角度
* @return 旋转后的图片
* @since 3.2.2
*/
public static BufferedImage rotate(Image image, int degree) {
return Img.from(image).rotate(degree).getImg();
}
// ---------------------------------------------------------------------------------------------------------------------- flip
/**
* 水平翻转图像
*
* @param imageFile 图像文件
* @param outFile 输出文件
* @throws IORuntimeException IO异常
* @since 3.2.2
*/
public static void flip(File imageFile, File outFile) throws IORuntimeException {
flip(read(imageFile), outFile);
}
/**
* 水平翻转图像
*
* @param image 图像
* @param outFile 输出文件
* @throws IORuntimeException IO异常
* @since 3.2.2
*/
public static void flip(Image image, File outFile) throws IORuntimeException {
write(flip(image), outFile);
}
/**
* 水平翻转图像
*
* @param image 图像
* @param out 输出
* @throws IORuntimeException IO异常
* @since 3.2.2
*/
public static void flip(Image image, OutputStream out) throws IORuntimeException {
flip(image, getImageOutputStream(out));
}
/**
* 水平翻转图像,写出格式为JPG
*
* @param image 图像
* @param out 输出
* @throws IORuntimeException IO异常
* @since 3.2.2
*/
public static void flip(Image image, ImageOutputStream out) throws IORuntimeException {
writeJpg(flip(image), out);
}
/**
* 水平翻转图像
*
* @param image 图像
* @return 翻转后的图片
* @since 3.2.2
*/
public static BufferedImage flip(Image image) {
return Img.from(image).flip().getImg();
}
// ---------------------------------------------------------------------------------------------------------------------- compress
/**
* 压缩图像,输出图像只支持jpg文件
*
* @param imageFile 图像文件
* @param outFile 输出文件,只支持jpg文件
* @throws IORuntimeException IO异常
* @since 4.3.2
*/
public static void compress(File imageFile, File outFile, float quality) throws IORuntimeException {
Img.from(imageFile).setQuality(quality).write(outFile);
}
// ---------------------------------------------------------------------------------------------------------------------- other
/**
* {@link Image} 转 {@link RenderedImage}<br>
* 首先尝试强转,否则新建一个{@link BufferedImage}后重新绘制
*
* @param img {@link Image}
* @return {@link BufferedImage}
* @since 4.3.2
*/
public static RenderedImage toRenderedImage(Image img) {
if (img instanceof RenderedImage) {
return (RenderedImage) img;
}
return copyImage(img, BufferedImage.TYPE_INT_RGB);
}
/**
* {@link Image} 转 {@link BufferedImage}<br>
* 首先尝试强转,否则新建一个{@link BufferedImage}后重新绘制
*
* @param img {@link Image}
* @return {@link BufferedImage}
*/
public static BufferedImage toBufferedImage(Image img) {
if (img instanceof BufferedImage) {
return (BufferedImage) img;
}
return copyImage(img, BufferedImage.TYPE_INT_RGB);
}
/**
* {@link Image} 转 {@link BufferedImage}<br>
* 如果源图片的RGB模式与目标模式一致,则直接转换,否则重新绘制
*
* @param image {@link Image}
* @param imageType 目标图片类型
* @return {@link BufferedImage}
* @since 4.3.2
*/
public static BufferedImage toBufferedImage(Image image, String imageType) {
BufferedImage bufferedImage;
if (false == imageType.equalsIgnoreCase(IMAGE_TYPE_PNG)) {
// 当目标为非PNG类图片时,源图片统一转换为RGB格式
if (image instanceof BufferedImage) {
bufferedImage = (BufferedImage) image;
if (BufferedImage.TYPE_INT_RGB != bufferedImage.getType()) {
bufferedImage = copyImage(image, BufferedImage.TYPE_INT_RGB);
}
} else {
bufferedImage = copyImage(image, BufferedImage.TYPE_INT_RGB);
}
} else {
bufferedImage = toBufferedImage(image);
}
return bufferedImage;
}
/**
* 将已有Image复制新的一份出来
*
* @param img {@link Image}
* @param imageType {@link BufferedImage}中的常量,图像类型,例如黑白等
* @return {@link BufferedImage}
* @see BufferedImage#TYPE_INT_RGB
* @see BufferedImage#TYPE_INT_ARGB
* @see BufferedImage#TYPE_INT_ARGB_PRE
* @see BufferedImage#TYPE_INT_BGR
* @see BufferedImage#TYPE_3BYTE_BGR
* @see BufferedImage#TYPE_4BYTE_ABGR
* @see BufferedImage#TYPE_4BYTE_ABGR_PRE
* @see BufferedImage#TYPE_BYTE_GRAY
* @see BufferedImage#TYPE_USHORT_GRAY
* @see BufferedImage#TYPE_BYTE_BINARY
* @see BufferedImage#TYPE_BYTE_INDEXED
* @see BufferedImage#TYPE_USHORT_565_RGB
* @see BufferedImage#TYPE_USHORT_555_RGB
*/
public static BufferedImage copyImage(Image img, int imageType) {
final BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), imageType);
final Graphics2D bGr = bimage.createGraphics();
bGr.drawImage(img, 0, 0, null);
bGr.dispose();
return bimage;
}
/**
* 将Base64编码的图像信息转为 {@link BufferedImage}
*
* @param base64 图像的Base64表示
* @return {@link BufferedImage}
* @throws IORuntimeException IO异常
*/
public static BufferedImage toImage(String base64) throws IORuntimeException {
byte[] decode = Base64.decode(base64, CharsetUtil.CHARSET_UTF_8);
return toImage(decode);
}
/**
* 将的图像bytes转为 {@link BufferedImage}
*
* @param imageBytes 图像bytes
* @return {@link BufferedImage}
* @throws IORuntimeException IO异常
*/
public static BufferedImage toImage(byte[] imageBytes) throws IORuntimeException {
return read(new ByteArrayInputStream(imageBytes));
}
/**
* 将图片对象转换为Base64形式
*
* @param image 图片对象
* @param imageType 图片类型
* @return Base64的字符串表现形式
* @since 4.1.8
*/
public static String toBase64(Image image, String imageType) {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
write(image, imageType, out);
return Base64.encode(out.toByteArray());
}
/**
* 根据文字创建PNG图片
*
* @param str 文字
* @param font 字体{@link Font}
* @param backgroundColor 背景颜色
* @param fontColor 字体颜色
* @param out 图片输出地
* @throws IORuntimeException IO异常
*/
public static void createImage(String str, Font font, Color backgroundColor, Color fontColor, ImageOutputStream out) throws IORuntimeException {
// 获取font的样式应用在str上的整个矩形
Rectangle2D r = font.getStringBounds(str, new FontRenderContext(AffineTransform.getScaleInstance(1, 1), false, false));
int unitHeight = (int) Math.floor(r.getHeight());// 获取单个字符的高度
// 获取整个str用了font样式的宽度这里用四舍五入后+1保证宽度绝对能容纳这个字符串作为图片的宽度
int width = (int) Math.round(r.getWidth()) + 1;
int height = unitHeight + 3;// 把单个字符的高度+3保证高度绝对能容纳字符串作为图片的高度
// 创建图片
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
Graphics g = image.getGraphics();
g.setColor(backgroundColor);
g.fillRect(0, 0, width, height);// 先用背景色填充整张图片,也就是背景
g.setColor(fontColor);
g.setFont(font);// 设置画笔字体
g.drawString(str, 0, font.getSize());// 画出字符串
g.dispose();
writePng(image, out);
}
/**
* 根据文件创建字体<br>
* 首先尝试创建{@link Font#TRUETYPE_FONT}字体,此类字体无效则创建{@link Font#TYPE1_FONT}
*
* @param fontFile 字体文件
* @return {@link Font}
* @since 3.0.9
*/
public static Font createFont(File fontFile) {
try {
return Font.createFont(Font.TRUETYPE_FONT, fontFile);
} catch (FontFormatException e) {
// True Type字体无效时使用Type1字体
try {
return Font.createFont(Font.TYPE1_FONT, fontFile);
} catch (Exception e1) {
throw new UtilException(e);
}
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
/**
* 根据文件创建字体<br>
* 首先尝试创建{@link Font#TRUETYPE_FONT}字体,此类字体无效则创建{@link Font#TYPE1_FONT}
*
* @param fontStream 字体流
* @return {@link Font}
* @since 3.0.9
*/
public static Font createFont(InputStream fontStream) {
try {
return Font.createFont(Font.TRUETYPE_FONT, fontStream);
} catch (FontFormatException e) {
// True Type字体无效时使用Type1字体
try {
return Font.createFont(Font.TYPE1_FONT, fontStream);
} catch (Exception e1) {
throw new UtilException(e1);
}
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
/**
* 创建{@link Graphics2D}
*
* @param image {@link BufferedImage}
* @param color {@link Color}背景颜色以及当前画笔颜色
* @return {@link Graphics2D}
* @since 3.2.3
*/
public static Graphics2D createGraphics(BufferedImage image, Color color) {
final Graphics2D g = image.createGraphics();
// 填充背景
g.setColor(color);
g.fillRect(0, 0, image.getWidth(), image.getHeight());
return g;
}
/**
* 写出图像为JPG格式
*
* @param image {@link Image}
* @param destImageStream 写出到的目标流
* @throws IORuntimeException IO异常
*/
public static void writeJpg(Image image, ImageOutputStream destImageStream) throws IORuntimeException {
write(image, IMAGE_TYPE_JPG, destImageStream);
}
/**
* 写出图像为PNG格式
*
* @param image {@link Image}
* @param destImageStream 写出到的目标流
* @throws IORuntimeException IO异常
*/
public static void writePng(Image image, ImageOutputStream destImageStream) throws IORuntimeException {
write(image, IMAGE_TYPE_PNG, destImageStream);
}
/**
* 写出图像为JPG格式
*
* @param image {@link Image}
* @param out 写出到的目标流
* @throws IORuntimeException IO异常
* @since 4.0.10
*/
public static void writeJpg(Image image, OutputStream out) throws IORuntimeException {
write(image, IMAGE_TYPE_JPG, out);
}
/**
* 写出图像为PNG格式
*
* @param image {@link Image}
* @param out 写出到的目标流
* @throws IORuntimeException IO异常
* @since 4.0.10
*/
public static void writePng(Image image, OutputStream out) throws IORuntimeException {
write(image, IMAGE_TYPE_PNG, out);
}
/**
* 写出图像
*
* @param image {@link Image}
* @param imageType 图片类型(图片扩展名)
* @param out 写出到的目标流
* @throws IORuntimeException IO异常
* @since 3.1.2
*/
public static void write(Image image, String imageType, OutputStream out) throws IORuntimeException {
write(image, imageType, getImageOutputStream(out));
}
/**
* 写出图像为指定格式
*
* @param image {@link Image}
* @param imageType 图片类型(图片扩展名)
* @param destImageStream 写出到的目标流
* @return 是否成功写出,如果返回false表示未找到合适的Writer
* @throws IORuntimeException IO异常
* @since 3.1.2
*/
public static boolean write(Image image, String imageType, ImageOutputStream destImageStream) throws IORuntimeException {
return write(image, imageType, destImageStream, 1);
}
/**
* 写出图像为指定格式
*
* @param image {@link Image}
* @param imageType 图片类型(图片扩展名)
* @param destImageStream 写出到的目标流
* @param quality 质量,数字为0~1(不包括0和1)表示质量压缩比,除此数字外设置表示不压缩
* @return 是否成功写出,如果返回false表示未找到合适的Writer
* @throws IORuntimeException IO异常
* @since 4.3.2
*/
public static boolean write(Image image, String imageType, ImageOutputStream destImageStream, float quality) throws IORuntimeException {
if (StrUtil.isBlank(imageType)) {
imageType = IMAGE_TYPE_JPG;
}
final ImageWriter writer = getWriter(image, imageType);
return write(toBufferedImage(image, imageType), writer, destImageStream, quality);
}
/**
* 写出图像为目标文件扩展名对应的格式
*
* @param image {@link Image}
* @param targetFile 目标文件
* @throws IORuntimeException IO异常
* @since 3.1.0
*/
public static void write(Image image, File targetFile) throws IORuntimeException {
ImageOutputStream out = null;
try {
out = getImageOutputStream(targetFile);
write(image, FileUtil.extName(targetFile), out);
} finally {
IoUtil.close(out);
}
}
/**
* 通过{@link ImageWriter}写出图片到输出流
*
* @param image 图片
* @param writer {@link ImageWriter}
* @param output 输出的Image流{@link ImageOutputStream}
* @param quality 质量,数字为0~1(不包括0和1)表示质量压缩比,除此数字外设置表示不压缩
* @return 是否成功写出
* @since 4.3.2
*/
public static boolean write(Image image, ImageWriter writer, ImageOutputStream output, float quality) {
if (writer == null) {
return false;
}
writer.setOutput(output);
final RenderedImage renderedImage = toRenderedImage(image);
// 设置质量
ImageWriteParam imgWriteParams = null;
if (quality > 0 && quality < 1) {
imgWriteParams = writer.getDefaultWriteParam();
if (imgWriteParams.canWriteCompressed()) {
imgWriteParams.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
imgWriteParams.setCompressionQuality(quality);
final ColorModel colorModel = renderedImage.getColorModel();// ColorModel.getRGBdefault();
imgWriteParams.setDestinationType(new ImageTypeSpecifier(colorModel, colorModel.createCompatibleSampleModel(16, 16)));
}
}
try {
if (null != imgWriteParams) {
writer.write(null, new IIOImage(renderedImage, null, null), imgWriteParams);
} else {
writer.write(renderedImage);
}
output.flush();
} catch (IOException e) {
throw new IORuntimeException(e);
} finally {
writer.dispose();
}
return true;
}
/**
* 获得{@link ImageReader}
*
* @param type 图片文件类型,例如 "jpeg" 或 "tiff"
* @return {@link ImageReader}
*/
public static ImageReader getReader(String type) {
final Iterator<ImageReader> iterator = ImageIO.getImageReadersByFormatName(type);
if (iterator.hasNext()) {
return iterator.next();
}
return null;
}
/**
* 从文件中读取图片,请使用绝对路径,使用相对路径会相对于ClassPath
*
* @param imageFilePath 图片文件路径
* @return 图片
* @since 4.1.15
*/
public static BufferedImage read(String imageFilePath) {
return read(FileUtil.file(imageFilePath));
}
/**
* 从文件中读取图片
*
* @param imageFile 图片文件
* @return 图片
* @since 3.2.2
*/
public static BufferedImage read(File imageFile) {
try {
return ImageIO.read(imageFile);
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
/**
* 从流中读取图片
*
* @param imageStream 图片文件
* @return 图片
* @since 3.2.2
*/
public static BufferedImage read(InputStream imageStream) {
try {
return ImageIO.read(imageStream);
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
/**
* 从图片流中读取图片
*
* @param imageStream 图片文件
* @return 图片
* @since 3.2.2
*/
public static BufferedImage read(ImageInputStream imageStream) {
try {
return ImageIO.read(imageStream);
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
/**
* 从URL中读取图片
*
* @param imageUrl 图片文件
* @return 图片
* @since 3.2.2
*/
public static BufferedImage read(URL imageUrl) {
try {
return ImageIO.read(imageUrl);
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
/**
* 获取{@link ImageOutputStream}
*
* @param out {@link OutputStream}
* @return {@link ImageOutputStream}
* @throws IORuntimeException IO异常
* @since 3.1.2
*/
public static ImageOutputStream getImageOutputStream(OutputStream out) throws IORuntimeException {
try {
return ImageIO.createImageOutputStream(out);
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
/**
* 获取{@link ImageOutputStream}
*
* @param outFile {@link File}
* @return {@link ImageOutputStream}
* @throws IORuntimeException IO异常
* @since 3.2.2
*/
public static ImageOutputStream getImageOutputStream(File outFile) throws IORuntimeException {
try {
return ImageIO.createImageOutputStream(outFile);
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
/**
* 获取{@link ImageInputStream}
*
* @param in {@link InputStream}
* @return {@link ImageInputStream}
* @throws IORuntimeException IO异常
* @since 3.1.2
*/
public static ImageInputStream getImageInputStream(InputStream in) throws IORuntimeException {
try {
return ImageIO.createImageInputStream(in);
} catch (IOException e) {
throw new IORuntimeException(e);
}
}
/**
* 根据给定的Image对象和格式获取对应的{@link ImageWriter},如果未找到合适的Writer,返回null
*
* @param img {@link Image}
* @param formatName 图片格式,例如"jpg"、"png"
* @return {@link ImageWriter}
* @since 4.3.2
*/
public static ImageWriter getWriter(Image img, String formatName) {
final ImageTypeSpecifier type = ImageTypeSpecifier.createFromRenderedImage(toRenderedImage(img));
final Iterator<ImageWriter> iter = ImageIO.getImageWriters(type, formatName);
return iter.hasNext() ? iter.next() : null;
}
/**
* 根据给定的图片格式或者扩展名获取{@link ImageWriter},如果未找到合适的Writer,返回null
*
* @param formatName 图片格式或扩展名,例如"jpg"、"png"
* @return {@link ImageWriter}
* @since 4.3.2
*/
public static ImageWriter getWriter(String formatName) {
ImageWriter writer = null;
Iterator<ImageWriter> iter = ImageIO.getImageWritersByFormatName(formatName);
if (iter.hasNext()) {
writer = iter.next();
}
if (null == writer) {
// 尝试扩展名获取
iter = ImageIO.getImageWritersBySuffix(formatName);
if (iter.hasNext()) {
writer = iter.next();
}
}
return writer;
}
// -------------------------------------------------------------------------------------------------------------------- Color
/**
* Color对象转16进制表示,例如#fcf6d6
*
* @param color {@link Color}
* @return 16进制的颜色值,例如#fcf6d6
* @since 4.1.14
*/
public static String toHex(Color color) {
String R = Integer.toHexString(color.getRed());
R = R.length() < 2 ? ('0' + R) : R;
String G = Integer.toHexString(color.getGreen());
G = G.length() < 2 ? ('0' + G) : G;
String B = Integer.toHexString(color.getBlue());
B = B.length() < 2 ? ('0' + B) : B;
return '#' + R + G + B;
}
/**
* 16进制的颜色值转换为Color对象,例如#fcf6d6
*
* @param hex 16进制的颜色值,例如#fcf6d6
* @return {@link Color}
* @since 4.1.14
*/
public static Color hexToColor(String hex) {
return getColor(Integer.parseInt(StrUtil.removePrefix("#", hex), 16));
}
/**
* 获取一个RGB值对应的颜色
*
* @param rgb RGB值
* @return {@link Color}
* @since 4.1.14
*/
public static Color getColor(int rgb) {
return new Color(rgb);
}
/**
* 将颜色值转换成具体的颜色类型 汇集了常用的颜色集,支持以下几种形式:
*
* <pre>
* 1. 颜色的英文名(大小写皆可)
* 2. 16进制表示,例如:#fcf6d6或者$fcf6d6
* 3. RGB形式,例如:13,148,252
* </pre>
*
* 方法来自:com.lnwazg.kit
*
* @param colorName 颜色的英文名,16进制表示或RGB表示
* @return {@link Color}
* @since 4.1.14
*/
public static Color getColor(String colorName) {
if (StrUtil.isBlank(colorName)) {
return null;
}
colorName = colorName.toUpperCase();
if ("BLACK".equals(colorName)) {
return Color.BLACK;
} else if ("WHITE".equals(colorName)) {
return Color.WHITE;
} else if ("LIGHTGRAY".equals(colorName) || "LIGHT_GRAY".equals(colorName)) {
return Color.LIGHT_GRAY;
} else if ("GRAY".equals(colorName)) {
return Color.GRAY;
} else if ("DARK_GRAY".equals(colorName) || "DARK_GRAY".equals(colorName)) {
return Color.DARK_GRAY;
} else if ("RED".equals(colorName)) {
return Color.RED;
} else if ("PINK".equals(colorName)) {
return Color.PINK;
} else if ("ORANGE".equals(colorName)) {
return Color.ORANGE;
} else if ("YELLOW".equals(colorName)) {
return Color.YELLOW;
} else if ("GREEN".equals(colorName)) {
return Color.GREEN;
} else if ("MAGENTA".equals(colorName)) {
return Color.MAGENTA;
} else if ("CYAN".equals(colorName)) {
return Color.CYAN;
} else if ("BLUE".equals(colorName)) {
return Color.BLUE;
} else if ("DARKGOLD".equals(colorName)) {
// 暗金色
return hexToColor("#9e7e67");
} else if ("LIGHTGOLD".equals(colorName)) {
// 亮金色
return hexToColor("#ac9c85");
} else if (StrUtil.startWith(colorName, '#')) {
return hexToColor(colorName);
} else if (StrUtil.startWith(colorName, '$')) {
// 由于#在URL传输中无法传输,因此用$代替#
return hexToColor("#" + colorName.substring(1));
} else {
// rgb值
final List<String> rgb = StrUtil.split(colorName, ',');
if (3 == rgb.size()) {
final Integer r = Convert.toInt(rgb.get(0));
final Integer g = Convert.toInt(rgb.get(1));
final Integer b = Convert.toInt(rgb.get(2));
if (false == ArrayUtil.hasNull(r, g, b)) {
return new Color(r, g, b);
}
} else {
return null;
}
}
return null;
}
/**
* 生成随机颜色
*
* @return 随机颜色
* @since 3.1.2
*/
public static Color randomColor() {
return randomColor(null);
}
/**
* 生成随机颜色
*
* @param random 随机对象 {@link Random}
* @return 随机颜色
* @since 3.1.2
*/
public static Color randomColor(Random random) {
if (null == random) {
random = RandomUtil.getRandom();
}
return new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255));
}
}
|
[
"dingjun@chinatvpay.com"
] |
dingjun@chinatvpay.com
|
79357513bdec3dd3761a35e7c9a650e99e3d5222
|
6c4d7f85fe9a868d14d78b21192eccf910086483
|
/NewBoston/src/main/java/Arithmetic.java
|
5668736adcb590794f88df0fb935f87e6e7abb2c
|
[] |
no_license
|
rohit-r-ganthade/my_git_repo
|
5ee165bc653adb87f018d5688bc436959d4fcd9b
|
cbc7dc09a885063e2f93057a307c90013e87150a
|
refs/heads/master
| 2021-05-12T06:58:49.929286
| 2018-01-28T11:37:32
| 2018-01-28T11:37:32
| 117,231,933
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 3,057
|
java
|
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Created by rohit on 03/09/17.
*/
public class Arithmetic {
public static void main(String args[]) throws IOException {
// Scanner scanner = new Scanner(System.in);
// double fnum, snum, answer;
//
// System.out.println("Enter first number");
// fnum = scanner.nextDouble();
//
// System.out.println("Enter second number");
// snum = scanner.nextDouble();
//
// answer = fnum + snum;
//
// System.out.println("Total of both the number's is");
// System.out.println(answer);
// String str = "java";
// char ch[] = str.toCharArray();
// for(int i = 0;i<ch.length;i++){
// int count=0;
// for (int j=0;j<ch.length;j++){
// if (ch[i]==ch[j])
// count++;
// }
// System.out.println( ch[i] + " is printed " + count + " times");
// }
// BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// System.out.print("Enter string: ");
// String s = br.readLine();
// String reverse = "";
// int length = s.length();
//
// for (int i = length - 1; i >= 0; i--)
// reverse = reverse + s.charAt(i);
// System.out.println("Result:" + reverse);
// String str = new Arithmetic().reverseWordByWord("Hello World");
// System.out.println(str);
// }
// public String reverseWordByWord(String str){
// int strLeng = str.length()-1;
// String reverse = "", temp = "";
//
// for(int i = 0; i <= strLeng; i++){
// temp += str.charAt(i);
// if((str.charAt(i) == ' ') || (i == strLeng)){
// for(int j = temp.length()-1; j >= 0; j--){
// reverse += temp.charAt(j);
// if((j == 0) )
// reverse += " ";
// }
// temp = "";
// }
// }
// return reverse;
String str = "java";
// char ch[] = str.toCharArray();
// for(int i = 0;i<ch.length;i++){
// int count=0;
// for (int j=0;j<ch.length;j++){
// if (ch[i]==ch[j])
// count++;
// }
// System.out.println( ch[i] + " is printed " + count + " times");
// }
Map<Character,Integer> map = new LinkedHashMap<>();
for (int i=0; i <str.length() ;i++){
if (map.get(str.charAt(i)) == null)
map.put(str.charAt(i), 1);
else
map.put(str.charAt(i), map.get(str.charAt(i))+1);
}
// System.out.println(map.toString());
// for (Map.Entry map1 : map.entrySet()){
// System.out.println(map1.getKey() + " is printed " + map1.getValue() + " times.");
// }
for (Character ch : map.keySet()){
System.out.println(ch + " is printed " + map.get(ch) + " times.");
}
}
}
|
[
"rohit.ganthade@gmail.com"
] |
rohit.ganthade@gmail.com
|
e612ea364d6729f38208fd5d1f64eb73045474b9
|
c8f6b4b4a643e9aeacecc50bebea7102cd4132e7
|
/Android/Ujoolt/src/com/fgsecure/ujoolt/app/utillity/LoadJoltTask.java
|
fb5fc72a425eb38e3202731143a5ef78f49583bb
|
[] |
no_license
|
paulomcnally/visva
|
c475a5c166662f7a2ac05413aec01021582a226e
|
e7bbf0559ffd77f7abcb6ba96fae9606a6e4876c
|
refs/heads/master
| 2021-01-22T10:21:43.082568
| 2015-07-05T18:08:58
| 2015-07-05T18:08:58
| 40,391,742
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,363
|
java
|
package com.fgsecure.ujoolt.app.utillity;
import android.util.Log;
import com.fgsecure.ujoolt.app.screen.MainScreenActivity;
import com.google.android.maps.GeoPoint;
public class LoadJoltTask implements Runnable {
MainScreenActivity mainScreenActivity;
public LoadJoltTask(MainScreenActivity mainScreenActivity) {
this.mainScreenActivity = mainScreenActivity;
}
@Override
public void run() {
Log.e("vap", "ok");
mainScreenActivity.curLati = 48895000;
mainScreenActivity.curLongi = 2282500;
mainScreenActivity.mapController.animateTo(new GeoPoint(mainScreenActivity.curLati,
mainScreenActivity.curLongi));
// mc.animateTo(new GeoPoint(48895000, 2282500));
mainScreenActivity.mapController.setZoom(17);
mainScreenActivity.mapView.invalidate();
// mainScreenActivity.joltHolder.setCoordinates(mainScreenActivity.curLati,
// mainScreenActivity.curLongi);
// mainScreenActivity.joltHolder.getAllJoltsFromLocation(
// mainScreenActivity.lati_jolt, mainScreenActivity.longi_jolt,
// ConfigUtility.getCurTimeStamp());
// mainScreenActivity.joltHolder.autoGenarateJoltBlues(
// mainScreenActivity.lati_jolt, mainScreenActivity.longi_jolt);
//
// mainScreenActivity.getArrayJoltAvailable();
// mainScreenActivity.mapView.regroupJolts();
// mainScreenActivity.displayJolts();
}
}
|
[
"kieuducthang@gmail.com"
] |
kieuducthang@gmail.com
|
b25c0ad664b7bfe4a87482774f391a2a802f5ec0
|
968b0f949fd91451b82e5c000ce80ee6fb66e999
|
/jt-manage-1/src/main/java/com/jt/vo/EasyUIList.java
|
8ca365b19b611990081f59f154b26cffd1f28ce2
|
[] |
no_license
|
Admin-k/STS-JT-1
|
5077145da68e31aa9681743511d82d3ed4a253e9
|
9cde0137bbcf0fdfc8255565ddcd4ade058996e7
|
refs/heads/master
| 2020-05-18T08:53:30.276612
| 2019-04-30T17:55:31
| 2019-04-30T17:55:31
| 184,308,545
| 3
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 404
|
java
|
package com.jt.vo;
import java.util.List;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain=true)
public class EasyUIList {
private Integer total; //记录总数
private List<?> rows; //保存商品信息
public EasyUIList(){
}
public EasyUIList(Integer total, List<?> rows) {
super();
this.total = total;
this.rows = rows;
}
}
|
[
"3215673330@qq.com"
] |
3215673330@qq.com
|
fc060a01df23c4391fea03bfba8f110f4ec3bea5
|
5dfadf842bdf166c604cdeecae309f45fe3f1a79
|
/src/com/msbinfo/expresslync/rct/valuation/impl/CalculationResultImpl.java
|
cb8aab6d08b6242412bcc2bd78cedf7479692227
|
[] |
no_license
|
JB2001216/MSBValuationClient
|
a9d86260ffbf16bd82216b60498704bb42259083
|
e2cf9299a8482ffdcc807c84fc3bd0ce6a83b0c8
|
refs/heads/master
| 2023-02-23T22:11:50.951025
| 2021-01-27T13:48:39
| 2021-01-27T13:48:39
| 333,434,368
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 27,931
|
java
|
/*
* XML Type: CalculationResult
* Namespace: http://msbinfo.com/expresslync/rct/valuation
* Java type: com.msbinfo.expresslync.rct.valuation.CalculationResult
*
* Automatically generated - do not modify.
*/
package com.msbinfo.expresslync.rct.valuation.impl;
/**
* An XML CalculationResult(@http://msbinfo.com/expresslync/rct/valuation).
*
* This is a complex type.
*/
public class CalculationResultImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements com.msbinfo.expresslync.rct.valuation.CalculationResult
{
public CalculationResultImpl(org.apache.xmlbeans.SchemaType sType)
{
super(sType);
}
private static final javax.xml.namespace.QName CALCUSER$0 =
new javax.xml.namespace.QName("http://msbinfo.com/expresslync/rct/valuation", "CalcUser");
private static final javax.xml.namespace.QName CALCDATE$2 =
new javax.xml.namespace.QName("http://msbinfo.com/expresslync/rct/valuation", "CalcDate");
private static final javax.xml.namespace.QName COSTDATAVERSION$4 =
new javax.xml.namespace.QName("http://msbinfo.com/expresslync/rct/valuation", "CostDataVersion");
private static final javax.xml.namespace.QName BUILDINGSYSTEMCOST$6 =
new javax.xml.namespace.QName("http://msbinfo.com/expresslync/rct/valuation", "BuildingSystemCost");
private static final javax.xml.namespace.QName PRIMARYSTRUCTURENONSTANDARDIZEDCOST$8 =
new javax.xml.namespace.QName("http://msbinfo.com/expresslync/rct/valuation", "PrimaryStructureNonStandardizedCost");
private static final javax.xml.namespace.QName PRIMARYSTRUCTURESTANDARDIZEDCOST$10 =
new javax.xml.namespace.QName("http://msbinfo.com/expresslync/rct/valuation", "PrimaryStructureStandardizedCost");
private static final javax.xml.namespace.QName DETACHEDSTRUCTURESNONSTANDARDDIZEDCOST$12 =
new javax.xml.namespace.QName("http://msbinfo.com/expresslync/rct/valuation", "DetachedStructuresNonStandarddizedCost");
private static final javax.xml.namespace.QName DETACHEDSTRUCTURESSTANDARDDIZEDCOST$14 =
new javax.xml.namespace.QName("http://msbinfo.com/expresslync/rct/valuation", "DetachedStructuresStandarddizedCost");
private static final javax.xml.namespace.QName WHOLEBUILDINGCOST$16 =
new javax.xml.namespace.QName("http://msbinfo.com/expresslync/rct/valuation", "WholeBuildingCost");
/**
* Gets the "CalcUser" element
*/
public java.lang.String getCalcUser()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target = null;
target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(CALCUSER$0, 0);
if (target == null)
{
return null;
}
return target.getStringValue();
}
}
/**
* Gets (as xml) the "CalcUser" element
*/
public org.apache.xmlbeans.XmlString xgetCalcUser()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.XmlString target = null;
target = (org.apache.xmlbeans.XmlString)get_store().find_element_user(CALCUSER$0, 0);
return target;
}
}
/**
* True if has "CalcUser" element
*/
public boolean isSetCalcUser()
{
synchronized (monitor())
{
check_orphaned();
return get_store().count_elements(CALCUSER$0) != 0;
}
}
/**
* Sets the "CalcUser" element
*/
public void setCalcUser(java.lang.String calcUser)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target = null;
target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(CALCUSER$0, 0);
if (target == null)
{
target = (org.apache.xmlbeans.SimpleValue)get_store().add_element_user(CALCUSER$0);
}
target.setStringValue(calcUser);
}
}
/**
* Sets (as xml) the "CalcUser" element
*/
public void xsetCalcUser(org.apache.xmlbeans.XmlString calcUser)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.XmlString target = null;
target = (org.apache.xmlbeans.XmlString)get_store().find_element_user(CALCUSER$0, 0);
if (target == null)
{
target = (org.apache.xmlbeans.XmlString)get_store().add_element_user(CALCUSER$0);
}
target.set(calcUser);
}
}
/**
* Unsets the "CalcUser" element
*/
public void unsetCalcUser()
{
synchronized (monitor())
{
check_orphaned();
get_store().remove_element(CALCUSER$0, 0);
}
}
/**
* Gets the "CalcDate" element
*/
public java.util.Calendar getCalcDate()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target = null;
target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(CALCDATE$2, 0);
if (target == null)
{
return null;
}
return target.getCalendarValue();
}
}
/**
* Gets (as xml) the "CalcDate" element
*/
public org.apache.xmlbeans.XmlDateTime xgetCalcDate()
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.XmlDateTime target = null;
target = (org.apache.xmlbeans.XmlDateTime)get_store().find_element_user(CALCDATE$2, 0);
return target;
}
}
/**
* Sets the "CalcDate" element
*/
public void setCalcDate(java.util.Calendar calcDate)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.SimpleValue target = null;
target = (org.apache.xmlbeans.SimpleValue)get_store().find_element_user(CALCDATE$2, 0);
if (target == null)
{
target = (org.apache.xmlbeans.SimpleValue)get_store().add_element_user(CALCDATE$2);
}
target.setCalendarValue(calcDate);
}
}
/**
* Sets (as xml) the "CalcDate" element
*/
public void xsetCalcDate(org.apache.xmlbeans.XmlDateTime calcDate)
{
synchronized (monitor())
{
check_orphaned();
org.apache.xmlbeans.XmlDateTime target = null;
target = (org.apache.xmlbeans.XmlDateTime)get_store().find_element_user(CALCDATE$2, 0);
if (target == null)
{
target = (org.apache.xmlbeans.XmlDateTime)get_store().add_element_user(CALCDATE$2);
}
target.set(calcDate);
}
}
/**
* Gets the "CostDataVersion" element
*/
public com.msbinfo.expresslync.rct.valuation.CostDataVersionType getCostDataVersion()
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.CostDataVersionType target = null;
target = (com.msbinfo.expresslync.rct.valuation.CostDataVersionType)get_store().find_element_user(COSTDATAVERSION$4, 0);
if (target == null)
{
return null;
}
return target;
}
}
/**
* True if has "CostDataVersion" element
*/
public boolean isSetCostDataVersion()
{
synchronized (monitor())
{
check_orphaned();
return get_store().count_elements(COSTDATAVERSION$4) != 0;
}
}
/**
* Sets the "CostDataVersion" element
*/
public void setCostDataVersion(com.msbinfo.expresslync.rct.valuation.CostDataVersionType costDataVersion)
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.CostDataVersionType target = null;
target = (com.msbinfo.expresslync.rct.valuation.CostDataVersionType)get_store().find_element_user(COSTDATAVERSION$4, 0);
if (target == null)
{
target = (com.msbinfo.expresslync.rct.valuation.CostDataVersionType)get_store().add_element_user(COSTDATAVERSION$4);
}
target.set(costDataVersion);
}
}
/**
* Appends and returns a new empty "CostDataVersion" element
*/
public com.msbinfo.expresslync.rct.valuation.CostDataVersionType addNewCostDataVersion()
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.CostDataVersionType target = null;
target = (com.msbinfo.expresslync.rct.valuation.CostDataVersionType)get_store().add_element_user(COSTDATAVERSION$4);
return target;
}
}
/**
* Unsets the "CostDataVersion" element
*/
public void unsetCostDataVersion()
{
synchronized (monitor())
{
check_orphaned();
get_store().remove_element(COSTDATAVERSION$4, 0);
}
}
/**
* Gets array of all "BuildingSystemCost" elements
*/
public com.msbinfo.expresslync.rct.valuation.BuildingSystemCost[] getBuildingSystemCostArray()
{
synchronized (monitor())
{
check_orphaned();
java.util.List targetList = new java.util.ArrayList();
get_store().find_all_element_users(BUILDINGSYSTEMCOST$6, targetList);
com.msbinfo.expresslync.rct.valuation.BuildingSystemCost[] result = new com.msbinfo.expresslync.rct.valuation.BuildingSystemCost[targetList.size()];
targetList.toArray(result);
return result;
}
}
/**
* Gets ith "BuildingSystemCost" element
*/
public com.msbinfo.expresslync.rct.valuation.BuildingSystemCost getBuildingSystemCostArray(int i)
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.BuildingSystemCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.BuildingSystemCost)get_store().find_element_user(BUILDINGSYSTEMCOST$6, i);
if (target == null)
{
throw new IndexOutOfBoundsException();
}
return target;
}
}
/**
* Returns number of "BuildingSystemCost" element
*/
public int sizeOfBuildingSystemCostArray()
{
synchronized (monitor())
{
check_orphaned();
return get_store().count_elements(BUILDINGSYSTEMCOST$6);
}
}
/**
* Sets array of all "BuildingSystemCost" element
*/
public void setBuildingSystemCostArray(com.msbinfo.expresslync.rct.valuation.BuildingSystemCost[] buildingSystemCostArray)
{
synchronized (monitor())
{
check_orphaned();
arraySetterHelper(buildingSystemCostArray, BUILDINGSYSTEMCOST$6);
}
}
/**
* Sets ith "BuildingSystemCost" element
*/
public void setBuildingSystemCostArray(int i, com.msbinfo.expresslync.rct.valuation.BuildingSystemCost buildingSystemCost)
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.BuildingSystemCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.BuildingSystemCost)get_store().find_element_user(BUILDINGSYSTEMCOST$6, i);
if (target == null)
{
throw new IndexOutOfBoundsException();
}
target.set(buildingSystemCost);
}
}
/**
* Inserts and returns a new empty value (as xml) as the ith "BuildingSystemCost" element
*/
public com.msbinfo.expresslync.rct.valuation.BuildingSystemCost insertNewBuildingSystemCost(int i)
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.BuildingSystemCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.BuildingSystemCost)get_store().insert_element_user(BUILDINGSYSTEMCOST$6, i);
return target;
}
}
/**
* Appends and returns a new empty value (as xml) as the last "BuildingSystemCost" element
*/
public com.msbinfo.expresslync.rct.valuation.BuildingSystemCost addNewBuildingSystemCost()
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.BuildingSystemCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.BuildingSystemCost)get_store().add_element_user(BUILDINGSYSTEMCOST$6);
return target;
}
}
/**
* Removes the ith "BuildingSystemCost" element
*/
public void removeBuildingSystemCost(int i)
{
synchronized (monitor())
{
check_orphaned();
get_store().remove_element(BUILDINGSYSTEMCOST$6, i);
}
}
/**
* Gets the "PrimaryStructureNonStandardizedCost" element
*/
public com.msbinfo.expresslync.rct.valuation.PrimaryStructureNonStandardizedCost getPrimaryStructureNonStandardizedCost()
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.PrimaryStructureNonStandardizedCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.PrimaryStructureNonStandardizedCost)get_store().find_element_user(PRIMARYSTRUCTURENONSTANDARDIZEDCOST$8, 0);
if (target == null)
{
return null;
}
return target;
}
}
/**
* True if has "PrimaryStructureNonStandardizedCost" element
*/
public boolean isSetPrimaryStructureNonStandardizedCost()
{
synchronized (monitor())
{
check_orphaned();
return get_store().count_elements(PRIMARYSTRUCTURENONSTANDARDIZEDCOST$8) != 0;
}
}
/**
* Sets the "PrimaryStructureNonStandardizedCost" element
*/
public void setPrimaryStructureNonStandardizedCost(com.msbinfo.expresslync.rct.valuation.PrimaryStructureNonStandardizedCost primaryStructureNonStandardizedCost)
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.PrimaryStructureNonStandardizedCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.PrimaryStructureNonStandardizedCost)get_store().find_element_user(PRIMARYSTRUCTURENONSTANDARDIZEDCOST$8, 0);
if (target == null)
{
target = (com.msbinfo.expresslync.rct.valuation.PrimaryStructureNonStandardizedCost)get_store().add_element_user(PRIMARYSTRUCTURENONSTANDARDIZEDCOST$8);
}
target.set(primaryStructureNonStandardizedCost);
}
}
/**
* Appends and returns a new empty "PrimaryStructureNonStandardizedCost" element
*/
public com.msbinfo.expresslync.rct.valuation.PrimaryStructureNonStandardizedCost addNewPrimaryStructureNonStandardizedCost()
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.PrimaryStructureNonStandardizedCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.PrimaryStructureNonStandardizedCost)get_store().add_element_user(PRIMARYSTRUCTURENONSTANDARDIZEDCOST$8);
return target;
}
}
/**
* Unsets the "PrimaryStructureNonStandardizedCost" element
*/
public void unsetPrimaryStructureNonStandardizedCost()
{
synchronized (monitor())
{
check_orphaned();
get_store().remove_element(PRIMARYSTRUCTURENONSTANDARDIZEDCOST$8, 0);
}
}
/**
* Gets the "PrimaryStructureStandardizedCost" element
*/
public com.msbinfo.expresslync.rct.valuation.PrimaryStructureStandardizedCost getPrimaryStructureStandardizedCost()
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.PrimaryStructureStandardizedCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.PrimaryStructureStandardizedCost)get_store().find_element_user(PRIMARYSTRUCTURESTANDARDIZEDCOST$10, 0);
if (target == null)
{
return null;
}
return target;
}
}
/**
* True if has "PrimaryStructureStandardizedCost" element
*/
public boolean isSetPrimaryStructureStandardizedCost()
{
synchronized (monitor())
{
check_orphaned();
return get_store().count_elements(PRIMARYSTRUCTURESTANDARDIZEDCOST$10) != 0;
}
}
/**
* Sets the "PrimaryStructureStandardizedCost" element
*/
public void setPrimaryStructureStandardizedCost(com.msbinfo.expresslync.rct.valuation.PrimaryStructureStandardizedCost primaryStructureStandardizedCost)
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.PrimaryStructureStandardizedCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.PrimaryStructureStandardizedCost)get_store().find_element_user(PRIMARYSTRUCTURESTANDARDIZEDCOST$10, 0);
if (target == null)
{
target = (com.msbinfo.expresslync.rct.valuation.PrimaryStructureStandardizedCost)get_store().add_element_user(PRIMARYSTRUCTURESTANDARDIZEDCOST$10);
}
target.set(primaryStructureStandardizedCost);
}
}
/**
* Appends and returns a new empty "PrimaryStructureStandardizedCost" element
*/
public com.msbinfo.expresslync.rct.valuation.PrimaryStructureStandardizedCost addNewPrimaryStructureStandardizedCost()
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.PrimaryStructureStandardizedCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.PrimaryStructureStandardizedCost)get_store().add_element_user(PRIMARYSTRUCTURESTANDARDIZEDCOST$10);
return target;
}
}
/**
* Unsets the "PrimaryStructureStandardizedCost" element
*/
public void unsetPrimaryStructureStandardizedCost()
{
synchronized (monitor())
{
check_orphaned();
get_store().remove_element(PRIMARYSTRUCTURESTANDARDIZEDCOST$10, 0);
}
}
/**
* Gets the "DetachedStructuresNonStandarddizedCost" element
*/
public com.msbinfo.expresslync.rct.valuation.DetachedStructureNonStandardizedCost getDetachedStructuresNonStandarddizedCost()
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.DetachedStructureNonStandardizedCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.DetachedStructureNonStandardizedCost)get_store().find_element_user(DETACHEDSTRUCTURESNONSTANDARDDIZEDCOST$12, 0);
if (target == null)
{
return null;
}
return target;
}
}
/**
* True if has "DetachedStructuresNonStandarddizedCost" element
*/
public boolean isSetDetachedStructuresNonStandarddizedCost()
{
synchronized (monitor())
{
check_orphaned();
return get_store().count_elements(DETACHEDSTRUCTURESNONSTANDARDDIZEDCOST$12) != 0;
}
}
/**
* Sets the "DetachedStructuresNonStandarddizedCost" element
*/
public void setDetachedStructuresNonStandarddizedCost(com.msbinfo.expresslync.rct.valuation.DetachedStructureNonStandardizedCost detachedStructuresNonStandarddizedCost)
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.DetachedStructureNonStandardizedCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.DetachedStructureNonStandardizedCost)get_store().find_element_user(DETACHEDSTRUCTURESNONSTANDARDDIZEDCOST$12, 0);
if (target == null)
{
target = (com.msbinfo.expresslync.rct.valuation.DetachedStructureNonStandardizedCost)get_store().add_element_user(DETACHEDSTRUCTURESNONSTANDARDDIZEDCOST$12);
}
target.set(detachedStructuresNonStandarddizedCost);
}
}
/**
* Appends and returns a new empty "DetachedStructuresNonStandarddizedCost" element
*/
public com.msbinfo.expresslync.rct.valuation.DetachedStructureNonStandardizedCost addNewDetachedStructuresNonStandarddizedCost()
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.DetachedStructureNonStandardizedCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.DetachedStructureNonStandardizedCost)get_store().add_element_user(DETACHEDSTRUCTURESNONSTANDARDDIZEDCOST$12);
return target;
}
}
/**
* Unsets the "DetachedStructuresNonStandarddizedCost" element
*/
public void unsetDetachedStructuresNonStandarddizedCost()
{
synchronized (monitor())
{
check_orphaned();
get_store().remove_element(DETACHEDSTRUCTURESNONSTANDARDDIZEDCOST$12, 0);
}
}
/**
* Gets the "DetachedStructuresStandarddizedCost" element
*/
public com.msbinfo.expresslync.rct.valuation.DetachedStructureStandardizedCost getDetachedStructuresStandarddizedCost()
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.DetachedStructureStandardizedCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.DetachedStructureStandardizedCost)get_store().find_element_user(DETACHEDSTRUCTURESSTANDARDDIZEDCOST$14, 0);
if (target == null)
{
return null;
}
return target;
}
}
/**
* True if has "DetachedStructuresStandarddizedCost" element
*/
public boolean isSetDetachedStructuresStandarddizedCost()
{
synchronized (monitor())
{
check_orphaned();
return get_store().count_elements(DETACHEDSTRUCTURESSTANDARDDIZEDCOST$14) != 0;
}
}
/**
* Sets the "DetachedStructuresStandarddizedCost" element
*/
public void setDetachedStructuresStandarddizedCost(com.msbinfo.expresslync.rct.valuation.DetachedStructureStandardizedCost detachedStructuresStandarddizedCost)
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.DetachedStructureStandardizedCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.DetachedStructureStandardizedCost)get_store().find_element_user(DETACHEDSTRUCTURESSTANDARDDIZEDCOST$14, 0);
if (target == null)
{
target = (com.msbinfo.expresslync.rct.valuation.DetachedStructureStandardizedCost)get_store().add_element_user(DETACHEDSTRUCTURESSTANDARDDIZEDCOST$14);
}
target.set(detachedStructuresStandarddizedCost);
}
}
/**
* Appends and returns a new empty "DetachedStructuresStandarddizedCost" element
*/
public com.msbinfo.expresslync.rct.valuation.DetachedStructureStandardizedCost addNewDetachedStructuresStandarddizedCost()
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.DetachedStructureStandardizedCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.DetachedStructureStandardizedCost)get_store().add_element_user(DETACHEDSTRUCTURESSTANDARDDIZEDCOST$14);
return target;
}
}
/**
* Unsets the "DetachedStructuresStandarddizedCost" element
*/
public void unsetDetachedStructuresStandarddizedCost()
{
synchronized (monitor())
{
check_orphaned();
get_store().remove_element(DETACHEDSTRUCTURESSTANDARDDIZEDCOST$14, 0);
}
}
/**
* Gets the "WholeBuildingCost" element
*/
public com.msbinfo.expresslync.rct.valuation.WholeBuildingCost getWholeBuildingCost()
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.WholeBuildingCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.WholeBuildingCost)get_store().find_element_user(WHOLEBUILDINGCOST$16, 0);
if (target == null)
{
return null;
}
return target;
}
}
/**
* True if has "WholeBuildingCost" element
*/
public boolean isSetWholeBuildingCost()
{
synchronized (monitor())
{
check_orphaned();
return get_store().count_elements(WHOLEBUILDINGCOST$16) != 0;
}
}
/**
* Sets the "WholeBuildingCost" element
*/
public void setWholeBuildingCost(com.msbinfo.expresslync.rct.valuation.WholeBuildingCost wholeBuildingCost)
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.WholeBuildingCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.WholeBuildingCost)get_store().find_element_user(WHOLEBUILDINGCOST$16, 0);
if (target == null)
{
target = (com.msbinfo.expresslync.rct.valuation.WholeBuildingCost)get_store().add_element_user(WHOLEBUILDINGCOST$16);
}
target.set(wholeBuildingCost);
}
}
/**
* Appends and returns a new empty "WholeBuildingCost" element
*/
public com.msbinfo.expresslync.rct.valuation.WholeBuildingCost addNewWholeBuildingCost()
{
synchronized (monitor())
{
check_orphaned();
com.msbinfo.expresslync.rct.valuation.WholeBuildingCost target = null;
target = (com.msbinfo.expresslync.rct.valuation.WholeBuildingCost)get_store().add_element_user(WHOLEBUILDINGCOST$16);
return target;
}
}
/**
* Unsets the "WholeBuildingCost" element
*/
public void unsetWholeBuildingCost()
{
synchronized (monitor())
{
check_orphaned();
get_store().remove_element(WHOLEBUILDINGCOST$16, 0);
}
}
}
|
[
"amymadden@fulldiscourse.com"
] |
amymadden@fulldiscourse.com
|
9ce7da9a5e347f5d6187c3faf7d0789302f8900d
|
e3c2722c5095d35fa95d3b73f10e95c830393fe6
|
/Javabasic/src/c_control/Ex05_while연습.java
|
7b4a0fa9bc02bd1693c67b983e1014b348546dd4
|
[] |
no_license
|
kwon64/web1
|
685bdb81c325c54992a552c59a3b412a57719198
|
484750018e507b39aeb669059b755664ea8fc3cb
|
refs/heads/master
| 2020-11-24T12:51:15.522690
| 2020-03-30T09:25:39
| 2020-03-30T09:25:39
| 228,152,651
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 719
|
java
|
package c_control;
public class Ex05_while연습 {
public static void main(String[] args) {
// 3 6 9 게임
// for(int i = 1; i<40; i++) {
// int su=i;
// boolean su369 = false;
//
// while(su !=0) {
// int na = su % 10;
//
// if(na==3 | na==6| na==9 ) {
// System.out.print("짝");
// su369 = true;
// }
// su /= 10;
// }
//
// if(su369)
// System.out.println();
// else System.out.print(i);
// }
int count = 0;
for(int i = 1; i<10000; i++) {
int su=i;
while(su != 0) {
int na = su % 10;
if(na==8) {
count++;
}
su /= 10;
}
}
System.out.println(count);
}
}
|
[
"Canon@DESKTOP-PL2F7PK"
] |
Canon@DESKTOP-PL2F7PK
|
ac5964ea3c7c01d2a2c08cba9e23c8e3bbb7e3a0
|
e534b67f68d67a1201ed273262c89de910a1794b
|
/app/src/main/java/com/example/gabriel/seatreservation/SeatActivity.java
|
d1a5d6dc1b0c4ada4514afc67d1c06d05f40c11e
|
[] |
no_license
|
gabrielzheng31/SeatReservation
|
7d11b82927bf0fb4ac3ea11ec299c4aca87a4016
|
af4b323471c43aa9f660d9cf42b28bae14ebf97e
|
refs/heads/master
| 2021-09-03T06:08:33.849002
| 2018-01-06T06:28:50
| 2018-01-06T06:28:50
| 112,686,791
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 13,201
|
java
|
package com.example.gabriel.seatreservation;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.app.AlertDialog;
import android.support.design.widget.Snackbar;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import com.example.gabriel.seatreservation.data.ReservationData;
import com.example.gabriel.seatreservation.data.SeatData;
import com.example.gabriel.seatreservation.data.UserData;
import com.example.gabriel.seatreservation.utils.Configure;
import com.example.gabriel.seatreservation.utils.HttpCallbackListener;
import com.example.gabriel.seatreservation.utils.HttpUtil;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import java.util.ArrayList;
import java.util.Calendar;
public class SeatActivity extends BaseActivity {
private SeatTable seatTableView;
private int row, col, checked_r, checked_c;
private Button button_confirm;
public static void setChecked_seat(Pair<Integer, Integer> temp) {
Configure.temp = temp;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_seat);
seatTableView = findViewById(R.id.seatView);
seatTableView.setScreenName("教409");//设置屏幕名称
seatTableView.setMaxSelected(1);//设置最多选中
row = col =7;
seatTableView.setData(row,col);
/*seatTableView.setSeatChecker(new SeatTable.SeatChecker() {
@Override
public boolean isValidSeat(int row, int column) {
if(column==2) {
return false;
}
return true;
}
@Override
public boolean isSold(int row, int column) {
if(row==6 && column==6 ||
row ==5 && column ==4 ||
row ==3 && column ==2){
return true;
}
return false;
}
@Override
public void checked(int row, int column) {
}
@Override
public void unCheck(int row, int column) {
}
@Override
public String[] checkedSeatTxt(int row, int column) {
return null;
}
});*/
final SeatTable.SeatChecker seatChecker = new SeatTable.SeatChecker() {
@Override
public boolean isValidSeat(int row, int column) {
return true;
}
@Override
public boolean isSold(int row, int column) {
Pair<Integer, Integer> temp = new Pair<>(row, column);
if (Configure.SEATMAP.contains(temp))
return true;
return false;
}
@Override
public void checked(int row, int column) {
}
@Override
public void unCheck(int row, int column) {
}
@Override
public String[] checkedSeatTxt(int row, int column) {
return new String[0];
}
};
/*HttpUtil.CheckFreeSeat(HttpUtil.time_string(1), new HttpCallbackListener() {
@Override
public void onFinish(String response) {
Log.d("456", response);
JsonParser jsonParser = new JsonParser();
JsonArray jsonArray = jsonParser.parse(response).getAsJsonArray();
ArrayList<SeatData> seatDataArrayList = new ArrayList<>();
Gson gson = new Gson();
for (JsonElement seat: jsonArray) {
SeatData seatData = gson.fromJson(seat, SeatData.class);
seatDataArrayList.add(seatData);
Log.d("7890", ""+seatData.getSeatStatus());
}
for (SeatData seatData: seatDataArrayList) {
Log.d("gcd", "status"+seatData.getSeatStatus());
if (seatData.getSeatStatus()) {
int r = (seatData.getSeatID() - 1) / row ;
int c = (seatData.getSeatID() - 1) % row ;
Log.d("asdf", r+" "+c);
Pair<Integer, Integer> temp = new Pair<>(r, c);
Configure.SEATMAP.add(temp);
}
}
}
@Override
public void onError(Exception e) {
}
});
*/
seatTableView.setSeatChecker(seatChecker);
final Calendar calendar = Calendar.getInstance();
final int hour = calendar.get(Calendar.HOUR_OF_DAY);
final int minute = calendar.get(Calendar.MINUTE);
final String start_hour = String.format("%02d", hour);
final String start_minute = String.format("%02d", 0);
String end_hour = String.format("%02d", hour+1);
String end_minute = String.format("%02d", 0);
final int[] start = new int[1];
final int[] end = new int[1];
final TextView start_time = findViewById(R.id.timepicker_start);
final TextView end_time = findViewById(R.id.timepicker_end);
start_time.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final TimePickerDialog timePickerDialog_start = new TimePickerDialog(SeatActivity.this,
R.style.TimePickerDialog, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int i, int i1) {
start[0] = i;
if (start[0] < 8 || start[0] > 21) {
AlertDialog.Builder builder = new AlertDialog.Builder(SeatActivity.this);
builder.setTitle("非法时间");
builder.setCancelable(true);
builder.setMessage("请选择其他时间");
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
builder.show();
start_time.setText("开始时间");
} else {
start_time.setText(i+":"+"00");
}
}
}, hour, minute, true);
timePickerDialog_start.show();
}
});
end_time.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final TimePickerDialog timePickerDialog_end = new TimePickerDialog(SeatActivity.this,
R.style.TimePickerDialog, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int i, int i1) {
end[0] = i;
if (start[0] == 0 || end[0] <= start[0] || end[0] > 22) {
AlertDialog.Builder builder = new AlertDialog.Builder(SeatActivity.this);
builder.setTitle("非法时间");
builder.setCancelable(true);
builder.setMessage("请选择其他时间");
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
builder.show();
end_time.setText("结束时间");
HttpUtil.CheckFreeSeat(start[0], end[0], new HttpCallbackListener() {
@Override
public void onFinish(String response) {
Log.d("456", response);
JsonParser jsonParser = new JsonParser();
JsonArray jsonArray = jsonParser.parse(response).getAsJsonArray();
ArrayList<SeatData> seatDataArrayList = new ArrayList<>();
Gson gson = new Gson();
for (JsonElement seat: jsonArray) {
SeatData seatData = gson.fromJson(seat, SeatData.class);
seatDataArrayList.add(seatData);
Log.d("7890", ""+seatData.getSeatStatus());
}
for (SeatData seatData: seatDataArrayList) {
Log.d("gcd", "status"+seatData.getSeatStatus());
if (seatData.getSeatStatus()) {
int r = (seatData.getSeatID() - 1) / row ;
int c = (seatData.getSeatID() - 1) % row ;
Log.d("asdf", r+" "+c);
Pair<Integer, Integer> temp = new Pair<>(r, c);
Configure.SEATMAP.add(temp);
}
}
}
@Override
public void onError(Exception e) {
}
});
} else {
end_time.setText(i+":"+"00");
}
}
}, hour, minute, true);
timePickerDialog_end.show();
}
});
button_confirm = findViewById(R.id.button_confirm);
button_confirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
if (Configure.TOKEN == null || TextUtils.isEmpty(Configure.TOKEN)) {
Snackbar.make(view, "您尚未登录", Snackbar.LENGTH_SHORT);
} else {
HttpUtil.GetReservedStatus(Configure.TOKEN, new HttpCallbackListener() {
@Override
public void onFinish(String response) {
Log.d("reservation", response);
Gson gson = new Gson();
UserData userData = gson.fromJson(response, UserData.class);
switch (userData.getResCode()) {
case 0:
HttpUtil.ReserveSeat((Configure.temp.first + 1) * row + Configure.temp.second + 1,
start[0], end[0], Configure.TOKEN, new HttpCallbackListener() {
@Override
public void onFinish(String response) {
MainActivity.actionStart(view.getContext());
}
@Override
public void onError(Exception e) {
}
});
Snackbar.make(view, "预约成功", Snackbar.LENGTH_SHORT).show();
SeatActivity.this.finish();
break;
case 1:
Snackbar.make(view, "您当前已有预约", Snackbar.LENGTH_SHORT).show();
break;
}
}
@Override
public void onError(Exception e) {
}
});
}
}
});
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
// TODO Auto-generated method stub
super.onWindowFocusChanged(hasFocus);
if(hasFocus){
}
}
public static void actionStart(Context context) {
Intent intent = new Intent(context, SeatActivity.class);
context.startActivity(intent);
}
}
|
[
"gabrielzheng31@163.com"
] |
gabrielzheng31@163.com
|
24cd1a663877b22c0f3205eea11b3ce0e004c44d
|
58f54e534ee8c600bdad9cc8821913db7bde5d83
|
/Intervals/erco_test/hedc/EDU/oswego/cs/dl/util/concurrent/SyncCollection.java
|
7553db82e2a8cb436b0a5087ce7a4d09ba9ae1ee
|
[
"MIT"
] |
permissive
|
nikomatsakiseth/eth-intervals-java
|
c7b1c2b645ba24e94e174d0a20b9dac711a66ff8
|
0130f596c5c87e0858f14e4f7d367eff5432c569
|
refs/heads/master
| 2021-01-25T03:49:16.238220
| 2010-11-07T14:13:50
| 2010-11-07T14:13:50
| 381,446
| 2
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 13,810
|
java
|
/*
File: SyncCollection.java
Originally written by Doug Lea and released into the public domain.
This may be used for any purposes whatsoever without acknowledgment.
Thanks for the assistance and support of Sun Microsystems Labs,
and everyone contributing, testing, and using this code.
History:
Date Who What
1Aug1998 dl Create public version
*/
package EDU.oswego.cs.dl.util.concurrent;
import java.util.*;
/**
* SyncCollections wrap Sync-based control around java.util.Collections.
* They are similar in operation to those provided
* by java.util.Collection.synchronizedCollection, but have
* several extended capabilities.
* <p>
* The Collection interface is conceptually broken into two
* parts for purposes of synchronization control. The purely inspective
* reader operations are:
* <ul>
* <li> size
* <li> isEmpty
* <li> toArray
* <li> contains
* <li> containsAll
* <li> iterator
* </ul>
* The possibly mutative writer operations (which are also
* the set of operations that are allowed to throw
* UnsupportedOperationException) are:
* <ul>
* <li> add
* <li> addAll
* <li> remove
* <li> clear
* <li> removeAll
* <li> retainAll
* </ul>
*
* <p>
* SyncCollections can be used with either Syncs or ReadWriteLocks.
* When used with
* single Syncs, the same lock is used as both the reader and writer lock.
* The SyncCollection class cannot itself guarantee that using
* a pair of read/write locks will always correctly protect objects, since
* Collection implementations are not precluded from internally
* performing hidden unprotected state changes within conceptually read-only
* operations. However, they do work with current java.util implementations.
* (Hopefully, implementations that do not provide this natural
* guarantee will be clearly documentented as such.)
* <p>
* This class provides a straight implementation of Collections interface.
* In order to conform to this interface, sync failures
* due to interruption do NOT result in InterruptedExceptions.
* Instead, upon detection of interruption,
* <ul>
* <li> All mutative operations convert the interruption to
* an UnsupportedOperationException, while also propagating
* the interrupt status of the thread. Thus, unlike normal
* java.util.Collections, SyncCollections can <em>transiently</em>
* behave as if mutative operations are not supported.
* <li> All read-only operations
* attempt to return a result even upon interruption. In some contexts,
* such results will be meaningless due to interference, but
* provide best-effort status indications that can be useful during
* recovery. The cumulative number of synchronization failures encountered
* during such operations is accessible using method
* <code>synchronizationFailures()</code>.
* Non-zero values may indicate serious program errors.
* </ul>
* <p>
* The iterator() method returns a SyncCollectionIterator with
* properties and methods that are analogous to those of SyncCollection
* itself: hasNext and next are read-only, and remove is mutative.
* These methods allow fine-grained controlled access, but do <em>NOT</em>
* preclude concurrent modifications from being interleaved with traversals,
* which may lead to ConcurrentModificationExceptions.
* However, the class also supports method <code>unprotectedIterator</code>
* that can be used in conjunction with the <code>readerSync</code> or
* <code>writerSync</code> methods to perform locked traversals. For example,
* to protect a block of reads:
* <pre>
* Sync lock = coll.readerSync();
* try {
* lock.acquire();
* try {
* Iterator it = coll.unprotectedIterator();
* while (it.hasNext())
* System.out.println(it.next());
* }
* finally {
* lock.release();
* }
* }
* catch (InterruptedException ex) { ... }
* </pre>
* If you need to protect blocks of writes, you must use some
* form of <em>reentrant</em> lock (for example <code>ReentrantLock</code>
* or <code>ReentrantWriterPreferenceReadWriteLock</code>) as the Sync
* for the collection in order to allow mutative methods to proceed
* while the current thread holds the lock. For example, you might
* need to hold a write lock during an initialization sequence:
* <pre>
* Collection c = new SyncCollection(new ArrayList(),
* new ReentrantWriterPreferenceReadWriteLock);
* // ...
* c.writeLock().acquire();
* try {
* for (...) {
* Object x = someStream.readObject();
* c.add(x); // would block if writeLock not reentrant
* }
* }
* catch (IOException iox) {
* ...
* }
* finally {
* c.writeLock().release();
* }
* catch (InterruptedException ex) { ... }
* </pre>
* <p>
* (It would normally be better practice here to not make the
* collection accessible until initialization is complete.)
* <p>
* This class does not specifically support use of
* timed synchronization through the attempt method. However,
* you can obtain this effect via
* the TimeoutSync class. For example:
* <pre>
* Mutex lock = new Mutex();
* TimeoutSync timedLock = new TimeoutSync(lock, 1000); // 1 sec timeouts
* Collection c = new SyncCollection(new HashSet(), timedlock);
* </pre>
* <p>
* The same can be done with read-write locks:
* <pre>
* ReadWriteLock rwl = new WriterPreferenceReadWriteLock();
* Sync rlock = new TimeoutSync(rwl.readLock(), 100);
* Sync wlock = new TimeoutSync(rwl.writeLock(), 100);
* Collection c = new SyncCollection(new HashSet(), rlock, wlock);
* </pre>
* <p>
* In addition to synchronization control, SyncCollections
* may be useful in any context requiring before/after methods
* surrounding collections. For example, you can use ObservableSync
* to arrange notifications on method calls to collections, as in:
* <pre>
* class X {
* Collection c;
*
* static class CollectionObserver implements ObservableSync.SyncObserver {
* public void onAcquire(Object arg) {
* Collection coll = (Collection) arg;
* System.out.println("Starting operation on" + coll);
* // Other plausible responses include performing integrity
* // checks on the collection, updating displays, etc
* }
* public void onRelease(Object arg) {
* Collection coll = (Collection) arg;
* System.out.println("Finished operation on" + coll);
* }
* }
*
* X() {
* ObservableSync s = new ObservableSync();
* c = new SyncCollection(new HashSet(), s);
* s.setNotificationArgument(c);
* CollectionObserver obs = new CollectionObserver();
* s.attach(obs);
* }
* ...
* }
* </pre>
*
* <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
* @see LayeredSync
* @see TimeoutSync
**/
public class SyncCollection implements Collection {
protected final Collection c_; // Backing Collection
protected final Sync rd_; // sync for read-only methods
protected final Sync wr_; // sync for mutative methods
protected final SynchronizedLong syncFailures_ = new SynchronizedLong(0);
/**
* Create a new SyncCollection protecting the given collection,
* and using the given sync to control both reader and writer methods.
* Common, reasonable choices for the sync argument include
* Mutex, ReentrantLock, and Semaphores initialized to 1.
* <p>
* <b>Sample Usage</b>
* <pre>
* Collection c = new SyncCollection(new ArrayList(), new Mutex());
* </pre>
**/
public SyncCollection(Collection collection, Sync sync) {
this (collection, sync, sync);
}
/**
* Create a new SyncCollection protecting the given collection,
* and using the given ReadWriteLock to control reader and writer methods.
* <p>
* <b>Sample Usage</b>
* <pre>
* Collection c = new SyncCollection(new HashSet(),
* new WriterPreferenceReadWriteLock());
* </pre>
**/
public SyncCollection(Collection collection, ReadWriteLock rwl) {
this (collection, rwl.readLock(), rwl.writeLock());
}
/**
* Create a new SyncCollection protecting the given collection,
* and using the given pair of locks to control reader and writer methods.
**/
public SyncCollection(Collection collection, Sync readLock, Sync writeLock) {
c_ = collection;
rd_ = readLock;
wr_ = writeLock;
}
/**
* Return the Sync object managing read-only operations
**/
public Sync readerSync() {
return rd_;
}
/**
* Return the Sync object managing mutative operations
**/
public Sync writerSync() {
return wr_;
}
/**
* Return the number of synchronization failures for read-only operations
**/
public long syncFailures() {
return syncFailures_.get();
}
/** Try to acquire sync before a reader operation; record failure **/
protected boolean beforeRead() {
try {
rd_.acquire();
return false;
}
catch (InterruptedException ex) {
syncFailures_.increment();
return true;
}
}
/** Clean up after a reader operation **/
protected void afterRead(boolean wasInterrupted) {
if (wasInterrupted) {
Thread.currentThread().interrupt();
}
else
rd_.release();
}
public int size() {
boolean wasInterrupted = beforeRead();
try {
return c_.size();
}
finally {
afterRead(wasInterrupted);
}
}
public boolean isEmpty() {
boolean wasInterrupted = beforeRead();
try {
return c_.isEmpty();
}
finally {
afterRead(wasInterrupted);
}
}
public boolean contains(Object o) {
boolean wasInterrupted = beforeRead();
try {
return c_.contains(o);
}
finally {
afterRead(wasInterrupted);
}
}
public Object[] toArray() {
boolean wasInterrupted = beforeRead();
try {
return c_.toArray();
}
finally {
afterRead(wasInterrupted);
}
}
public Object[] toArray(Object[] a) {
boolean wasInterrupted = beforeRead();
try {
return c_.toArray(a);
}
finally {
afterRead(wasInterrupted);
}
}
public boolean containsAll(Collection coll) {
boolean wasInterrupted = beforeRead();
try {
return c_.containsAll(coll);
}
finally {
afterRead(wasInterrupted);
}
}
public boolean add(Object o) {
try {
wr_.acquire();
try {
return c_.add(o);
}
finally {
wr_.release();
}
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new UnsupportedOperationException();
}
}
public boolean remove(Object o) {
try {
wr_.acquire();
try {
return c_.remove(o);
}
finally {
wr_.release();
}
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new UnsupportedOperationException();
}
}
public boolean addAll(Collection coll) {
try {
wr_.acquire();
try {
return c_.addAll(coll);
}
finally {
wr_.release();
}
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new UnsupportedOperationException();
}
}
public boolean removeAll(Collection coll) {
try {
wr_.acquire();
try {
return c_.removeAll(coll);
}
finally {
wr_.release();
}
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new UnsupportedOperationException();
}
}
public boolean retainAll(Collection coll) {
try {
wr_.acquire();
try {
return c_.retainAll(coll);
}
finally {
wr_.release();
}
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new UnsupportedOperationException();
}
}
public void clear() {
try {
wr_.acquire();
try {
c_.clear();
}
finally {
wr_.release();
}
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new UnsupportedOperationException();
}
}
/** Return the base iterator of the underlying collection **/
public Iterator unprotectedIterator() {
boolean wasInterrupted = beforeRead();
try {
return c_.iterator();
}
finally {
afterRead(wasInterrupted);
}
}
public Iterator iterator() {
boolean wasInterrupted = beforeRead();
try {
return new SyncCollectionIterator(c_.iterator());
}
finally {
afterRead(wasInterrupted);
}
}
public class SyncCollectionIterator implements Iterator {
protected final Iterator baseIterator_;
SyncCollectionIterator(Iterator baseIterator) {
baseIterator_ = baseIterator;
}
public boolean hasNext() {
boolean wasInterrupted = beforeRead();
try {
return baseIterator_.hasNext();
}
finally {
afterRead(wasInterrupted);
}
}
public Object next() {
boolean wasInterrupted = beforeRead();
try {
return baseIterator_.next();
}
finally {
afterRead(wasInterrupted);
}
}
public void remove() {
try {
wr_.acquire();
try {
baseIterator_.remove();
}
finally {
wr_.release();
}
}
catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new UnsupportedOperationException();
}
}
}
}
|
[
"niko@alum.mit.edu"
] |
niko@alum.mit.edu
|
331381849bc59fdc9694afd56e0ea4772331c201
|
82144434e1d95da01a63beba1e285ad36382ad14
|
/jcart-store-back/src/main/java/io/mqs/jcartstoreback/dto/out/OrderHistoryListOutDTO.java
|
56c4fca29b5eeb01886a28de2d3559e524161a92
|
[] |
no_license
|
mengqisong/GitTest
|
fd4d57dff577809a9a9f95e65cd68b478035bf8e
|
e9b4e451bdfd2bd836e264ac25c92803496bbd87
|
refs/heads/master
| 2022-07-01T13:37:21.136072
| 2020-03-20T13:45:04
| 2020-03-20T13:45:04
| 242,697,777
| 0
| 0
| null | 2022-06-17T02:59:15
| 2020-02-24T09:41:30
|
JavaScript
|
UTF-8
|
Java
| false
| false
| 638
|
java
|
package io.mqs.jcartstoreback.dto.out;
public class OrderHistoryListOutDTO {
private Long timestamp;
private Byte orderStatus;
private String comment;
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
public Byte getOrderStatus() {
return orderStatus;
}
public void setOrderStatus(Byte orderStatus) {
this.orderStatus = orderStatus;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
}
|
[
"1160510138@qq.com"
] |
1160510138@qq.com
|
5128d9cd298201dd7356d569e2b65dc963ab30bb
|
8e686812073fcc41b5a14676eb0870f79e541009
|
/app/src/main/java/com/enggemy22/matajer2/Main/model2.java
|
89917255a2543e768d40d32d171ea2e7f8d9d908
|
[] |
no_license
|
mohamedgemy22/mtajer
|
07a3d83624476a4a9f950c1e22f131f27f62dfa7
|
3b278a9fa584bb5e71f17dfae10e20cb955ef400
|
refs/heads/master
| 2020-09-08T21:05:45.563747
| 2019-11-12T14:53:18
| 2019-11-12T14:53:18
| 221,241,204
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 465
|
java
|
package com.enggemy22.matajer2.Main;
public class model2 {
String name;
String id;
int imageRecource;
public model2(String name, String id, int imageRecource) {
this.name = name;
this.id = id;
this.imageRecource = imageRecource;
}
public String getName() {
return name;
}
public String getId() {
return id;
}
public int getImageRecource() {
return imageRecource;
}
}
|
[
"eng22mohamed10gemy20@gmail.com"
] |
eng22mohamed10gemy20@gmail.com
|
aae50d9bc57aa4f48b91f9edf7f9e99ceeaa9e05
|
6c1775660e770cf2a97c015181b1b6ea9131ccbc
|
/app/src/main/java/com/example/quanylysinhvien/database/DBHeplper.java
|
19f017a1b89298d4bb86ba18b4aef8b42489f591
|
[] |
no_license
|
lehuuquockhanh/120THLTDD01
|
a0789320e5983e5e752a593538b79896913b82d4
|
2a9868f432e9ea45b21aa1957b082cc241c404de
|
refs/heads/master
| 2023-02-01T11:59:53.968624
| 2020-12-14T15:07:12
| 2020-12-14T15:07:12
| 321,380,739
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,357
|
java
|
package com.example.quanylysinhvien.database;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import androidx.annotation.Nullable;
import com.example.quanylysinhvien.R;
import com.example.quanylysinhvien.model.SinhVien;
import java.util.ArrayList;
public class DBHeplper extends SQLiteOpenHelper {
public DBHeplper(@Nullable Context context) {
super(context, "QUANLYSINHVIENFPTDB.sqlite", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
String sql = " CREATE TABLE LOP(maLop TEXT PRIMARY KEY, tenLop TEXT)";
db.execSQL(sql);
sql = " INSERT INTO LOP VALUES ('LT1','Lap Trinh Di Dong')";
db.execSQL(sql);
sql = " INSERT INTO LOP VALUES ('LT2','Lap Trinh PHP')";
db.execSQL(sql);
sql = " INSERT INTO LOP VALUES ('LT3','Lap Trinh C#')";
db.execSQL(sql);
sql = " CREATE TABLE SINHVIEN(maSv TEXT PRIMARY KEY, tenSV TEXT ," + " email TEXT ,hinh TEXT, maLop TEXT REFERENCES LOP(maLop))";
db.execSQL(sql);
sql = " INSERT INTO SINHVIEN VALUES ('001','Nguyen Van Que','nguyenvanque@gmail.com','avatame','LT1')";
db.execSQL(sql);
sql = " INSERT INTO SINHVIEN VALUES ('002','Tran Thi Truc','tranthitruc@gmail.com','tranthitruc','LT2')";
db.execSQL(sql);
sql = " INSERT INTO SINHVIEN VALUES ('003','Tran Quoc Nguyen','quocnguyen@gmail.com','avatamacdinh','LT3')";
db.execSQL(sql);
sql = " INSERT INTO SINHVIEN VALUES ('004','Duong Tue Linh','tuelinh@gmail.com','duongtuelinh','LT1')";
db.execSQL(sql);
sql = " INSERT INTO SINHVIEN VALUES ('005','Tran Van Nam','vannam@gmail.com','tranvannam','LT2')";
db.execSQL(sql);
sql = " INSERT INTO SINHVIEN VALUES ('006','Nguyen Van Hung','vanhung@gmail.com','nguyenvanhung','LT3')";
db.execSQL(sql);
sql = "CREATE TABLE taiKhoan(tenTaiKhoan text primary key, matKhau text)";
db.execSQL(sql);
sql = "INSERT INTO taiKhoan VALUES('admin','admin')";
db.execSQL(sql);
sql = "INSERT INTO taiKhoan VALUES('admin1','admin1')";
db.execSQL(sql);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
|
[
"you@example.com"
] |
you@example.com
|
b652010deecfe13d7e06825b6f13f6a1615fa447
|
5c04b381f3ccf5e75000ca4dcac868f693a96f80
|
/classes/android/support/v4/h/o.java
|
455fde70290ae4bb0022ab40ca49b1e5ed03528f
|
[] |
no_license
|
BoUnCe587/IrataJaguar
|
7ce3e16cd821dc3f470ccdef63a19ebdb421e2db
|
b2a46d0f761439119cc7e3fffd8a8a6b83266d2d
|
refs/heads/master
| 2020-11-28T01:34:46.869006
| 2019-12-23T04:13:08
| 2019-12-23T04:13:08
| 198,387,252
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 489
|
java
|
package android.support.v4.h;
import android.view.View;
class o {
public static int a(View paramView) { return paramView.getMinimumHeight(); }
public static void a(View paramView, Runnable paramRunnable) { paramView.postOnAnimation(paramRunnable); }
public static void a(View paramView, Runnable paramRunnable, long paramLong) { paramView.postOnAnimationDelayed(paramRunnable, paramLong); }
public static void b(View paramView) { paramView.requestFitSystemWindows(); }
}
|
[
"James_McNamee123@hotmail.com"
] |
James_McNamee123@hotmail.com
|
35aa75329132abd8956fd9112a6410361fc62adb
|
8eaae5d589e94da4ace9981e44ff5f6475e0391a
|
/src/main/java/com/lazooo/example/Main.java
|
b5d118ce9248336de6c49cf18a3e9b08f6c0b23e
|
[
"MIT"
] |
permissive
|
giok57/async-servlet
|
5d3e0797156ec2b202ec3e59cf448bd5cfacd08c
|
44a637d282ed7d5489b1117392416a333d4ea00f
|
refs/heads/master
| 2020-05-05T02:38:01.570084
| 2013-12-04T01:52:45
| 2013-12-04T01:52:45
| 14,887,700
| 1
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,913
|
java
|
package com.lazooo.example; /**
The MIT License (MIT)
Copyright (c) 2013 Lazooo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
LazoooTeam
*/
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.webapp.WebAppContext;
/**
* @author giok57
* @email gioelemeoni@gmail.com
* @modifiedBy giok57
* <p/>
* Date: 30/11/13
* Time: 23:54
*/
public class Main {
public static void main(String[] args) throws Exception {
Server server = new Server();
ServerConnector s = new ServerConnector(server);
s.setPort(8080);
server.addConnector(s);
WebAppContext context = new WebAppContext();
context.setDefaultsDescriptor( "./webapp/WEB-INF/web.xml");
context.setResourceBase("./webapp/");
context.setContextPath("/");
server.setHandler(context);
server.start();
}
}
|
[
"gioelemeoni@gmail.com"
] |
gioelemeoni@gmail.com
|
41746ad8520ac9d704088c9c37b778b7b81eca8f
|
4d41728f620d6be9916b3c8446da9e01da93fa4c
|
/src/main/java/org/bukkit/permissions/PermissionAttachment.java
|
2972d99a817a5d6c257a0b23adfacd674982af42
|
[] |
no_license
|
TechCatOther/um_bukkit
|
a634f6ccf7142b2103a528bba1c82843c0bc4e44
|
836ed7a890b2cb04cd7847eff2c59d7a2f6d4d7b
|
refs/heads/master
| 2020-03-22T03:13:57.898936
| 2018-07-02T09:20:00
| 2018-07-02T09:20:00
| 139,420,415
| 3
| 2
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 3,644
|
java
|
package org.bukkit.permissions;
import org.bukkit.plugin.Plugin;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Holds information about a permission attachment on a {@link Permissible}
* object
*/
public class PermissionAttachment
{
private PermissionRemovedExecutor removed;
private final Map<String, Boolean> permissions = new LinkedHashMap<String, Boolean>();
private final Permissible permissible;
private final Plugin plugin;
public PermissionAttachment(Plugin plugin, Permissible Permissible)
{
if(plugin == null)
{
throw new IllegalArgumentException("Plugin cannot be null");
}
else if(!plugin.isEnabled())
{
throw new IllegalArgumentException("Plugin " + plugin.getDescription().getFullName() + " is disabled");
}
this.permissible = Permissible;
this.plugin = plugin;
}
/**
* Gets the plugin responsible for this attachment
*
* @return Plugin responsible for this permission attachment
*/
public Plugin getPlugin()
{
return plugin;
}
/**
* Sets an object to be called for when this attachment is removed from a
* {@link Permissible}. May be null.
*
* @param ex Object to be called when this is removed
*/
public void setRemovalCallback(PermissionRemovedExecutor ex)
{
removed = ex;
}
/**
* Gets the class that was previously set to be called when this
* attachment was removed from a {@link Permissible}. May be null.
*
* @return Object to be called when this is removed
*/
public PermissionRemovedExecutor getRemovalCallback()
{
return removed;
}
/**
* Gets the Permissible that this is attached to
*
* @return Permissible containing this attachment
*/
public Permissible getPermissible()
{
return permissible;
}
/**
* Gets a copy of all set permissions and values contained within this
* attachment.
* <p>
* This map may be modified but will not affect the attachment, as it is a
* copy.
*
* @return Copy of all permissions and values expressed by this attachment
*/
public Map<String, Boolean> getPermissions()
{
return new LinkedHashMap<String, Boolean>(permissions);
}
/**
* Sets a permission to the given value, by its fully qualified name
*
* @param name Name of the permission
* @param value New value of the permission
*/
public void setPermission(String name, boolean value)
{
permissions.put(name.toLowerCase(), value);
permissible.recalculatePermissions();
}
/**
* Sets a permission to the given value
*
* @param perm Permission to set
* @param value New value of the permission
*/
public void setPermission(Permission perm, boolean value)
{
setPermission(perm.getName(), value);
}
/**
* Removes the specified permission from this attachment.
* <p>
* If the permission does not exist in this attachment, nothing will
* happen.
*
* @param name Name of the permission to remove
*/
public void unsetPermission(String name)
{
permissions.remove(name.toLowerCase());
permissible.recalculatePermissions();
}
/**
* Removes the specified permission from this attachment.
* <p>
* If the permission does not exist in this attachment, nothing will
* happen.
*
* @param perm Permission to remove
*/
public void unsetPermission(Permission perm)
{
unsetPermission(perm.getName());
}
/**
* Removes this attachment from its registered {@link Permissible}
*
* @return true if the permissible was removed successfully, false if it
* did not exist
*/
public boolean remove()
{
try
{
permissible.removeAttachment(this);
return true;
} catch(IllegalArgumentException ex)
{
return false;
}
}
}
|
[
"alone.inbox@gmail.com"
] |
alone.inbox@gmail.com
|
147bbee6445b58fa3b8eb7caa74a79be8ba75646
|
f2e773d7a75bb24d104784ed9377c7634128e9da
|
/Powitalny.java
|
763828dbb079e112fbaa58116dcd98a00c7c4bf3
|
[] |
no_license
|
PiotrWrona/Sssnake
|
a2f7b5c93b5bcde7cc3b3cc93a12e7947a5f1f73
|
8fd39655193a5e77ef4c9cce9789232cd0caeccf
|
refs/heads/master
| 2021-01-10T20:22:41.662266
| 2015-03-16T15:30:15
| 2015-03-16T15:30:15
| 32,329,686
| 0
| 0
| null | null | null | null |
WINDOWS-1250
|
Java
| false
| false
| 2,908
|
java
|
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
/**
* Tworzy ekran powitalny w grze, gdzie możemy wybrać:
* <ul>
* <li>poziom trudnosci gry (szybkosc gry)</li>
* <li>oraz okreslić, czy uderzenie w ścianę kończy grę.</li>
* </ul>
*
* @version 1.0
*
*/
public class Powitalny extends JFrame implements ActionListener{
private JButton graj;
private JLabel poziomPredkosciTxt, scianyTxt;
private ButtonGroup poziomPredkosciButtonGroup;
private JCheckBox scianyTxtCheckbox;
private JRadioButton wolneRB, srednieRB, szybkieRB;
static boolean gra;
/**
* Konstruuje ekran powitalny
*/
public Powitalny(){
setSize(300,350);
setTitle("Sssnake");
setLayout(null);
poziomPredkosciTxt = new JLabel("Wybierz poziom trudnosci");
poziomPredkosciTxt.setBounds(20, 20, 300, 40);
add(poziomPredkosciTxt);
poziomPredkosciButtonGroup = new ButtonGroup();
wolneRB = new JRadioButton("pooowloolnie", false);
wolneRB.setBounds(20, 60, 150, 20);
poziomPredkosciButtonGroup.add(wolneRB);
add(wolneRB);
wolneRB.addActionListener(this);
srednieRB = new JRadioButton("srednio", true);
srednieRB.setBounds(20, 80, 150, 20);
poziomPredkosciButtonGroup.add(srednieRB);
add(srednieRB);
srednieRB.addActionListener(this);
szybkieRB = new JRadioButton("sz..bko", false);
szybkieRB.setBounds(20, 100, 150, 20);
poziomPredkosciButtonGroup.add(szybkieRB);
add(szybkieRB);
szybkieRB.addActionListener(this);
scianyTxt = new JLabel("Czy usunąć ograniczenia ścian?");
scianyTxt.setBounds(20, 150, 300, 40);
add(scianyTxt);
scianyTxtCheckbox = new JCheckBox("Tak");
scianyTxtCheckbox.setBounds(20, 180, 80, 40);
add(scianyTxtCheckbox);
scianyTxtCheckbox.addActionListener(this);
graj = new JButton("GRAJ !");
graj.setBounds(100, 250, 100, 40);
add(graj);
graj.addActionListener(this);
}
static Powitalny oknoP = new Powitalny();
public static void main(String[] args) {
oknoP.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
oknoP.setBounds(100,20,300,350);
oknoP.setVisible(true);
while (!gra);
Plansza plansza = new Plansza();
plansza.run();
}
/**
* Obsługa zdarzeń wyboru poziomu trudności oraz uderzenia węża w ścianę
*/
public void actionPerformed(ActionEvent e) {
Object zdarzenie = e.getSource();
if (zdarzenie == graj){
oknoP.setVisible(false);
gra = true;
}
if (zdarzenie == scianyTxtCheckbox){
if (Gra.czySaSciany) Gra.czySaSciany = false;
else Gra.czySaSciany = true;
}
if (zdarzenie == wolneRB) Gra.szybkoscGry = 600;
if (zdarzenie == srednieRB) Gra.szybkoscGry = 300;
if (zdarzenie == szybkieRB) Gra.szybkoscGry = 100;
}
}
|
[
"vincit@interia.pl"
] |
vincit@interia.pl
|
da2fae33d7d9cdaa8093e31e5ac73af32c432f15
|
a5d01febfd8d45a61f815b6f5ed447e25fad4959
|
/Source Code/5.5.1/sources/com/iqoption/chat/viewmodel/UserInfoViewModel$loadUserInfo$2.java
|
9408325e1f6cf92c07d80e8c0d0d2d8833c81943
|
[] |
no_license
|
kkagill/Decompiler-IQ-Option
|
7fe5911f90ed2490687f5d216cb2940f07b57194
|
c2a9dbbe79a959aa1ab8bb7a89c735e8f9dbc5a6
|
refs/heads/master
| 2020-09-14T20:44:49.115289
| 2019-11-04T06:58:55
| 2019-11-04T06:58:55
| 223,236,327
| 1
| 0
| null | 2019-11-21T18:17:17
| 2019-11-21T18:17:16
| null |
UTF-8
|
Java
| false
| false
| 1,261
|
java
|
package com.iqoption.chat.viewmodel;
import kotlin.i;
import kotlin.jvm.a.b;
import kotlin.jvm.internal.Lambda;
import kotlin.jvm.internal.h;
import kotlin.l;
@i(aXC = {1, 1, 11}, aXD = {"\u0000\u000e\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u0003\n\u0000\u0010\u0000\u001a\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u0003H\n¢\u0006\u0002\b\u0004"}, aXE = {"<anonymous>", "", "error", "", "invoke"})
/* compiled from: UserInfoViewModel.kt */
final class UserInfoViewModel$loadUserInfo$2 extends Lambda implements b<Throwable, l> {
final /* synthetic */ long $countryId;
final /* synthetic */ long $userId;
final /* synthetic */ UserInfoViewModel this$0;
UserInfoViewModel$loadUserInfo$2(UserInfoViewModel userInfoViewModel, long j, long j2) {
this.this$0 = userInfoViewModel;
this.$userId = j;
this.$countryId = j2;
super(1);
}
public /* synthetic */ Object invoke(Object obj) {
q((Throwable) obj);
return l.etX;
}
public final void q(Throwable th) {
h.e(th, "error");
if (!this.this$0.aLX) {
com.iqoption.core.i.w(UserInfoViewModel.TAG, th.getMessage(), th);
this.this$0.o(this.$userId, this.$countryId);
}
}
}
|
[
"yihsun1992@gmail.com"
] |
yihsun1992@gmail.com
|
83841913098ed143a40c2059d22915bb10bb8f80
|
9948394677a548ca62b3fc25f0363aa872c50710
|
/src/com/mliddy/calcengine/CalculateBase.java
|
d1ddf1a035362ca24de1164891ef1c29cd8316b1
|
[] |
no_license
|
mliddy/Calcengine
|
3014fe2bc360ab22ce86617ac8935b4cc1950cf4
|
b34b48789f61b01b01fc3f68eb2342f391db8481
|
refs/heads/master
| 2022-11-11T18:34:27.574183
| 2020-06-26T08:29:01
| 2020-06-26T08:29:01
| 275,110,940
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 805
|
java
|
package com.mliddy.calcengine;
public abstract class CalculateBase {
private double leftVal;
private double rightVal;
private double result;
public CalculateBase(){};
public CalculateBase(double leftVal, double rightVal) {
this.leftVal = leftVal;
this.rightVal = rightVal;
}
public abstract void calculate();
public double getLeftVal() {
return leftVal;
}
public void setLeftVal(double leftVal) {
this.leftVal = leftVal;
}
public double getRightVal() {
return rightVal;
}
public void setRightVal(double rightVal) {
this.rightVal = rightVal;
}
public double getResult() {
return result;
}
public void setResult(double result) {
this.result = result;
}
}
|
[
"mliddy@gmail.com"
] |
mliddy@gmail.com
|
46305679b7c7e1b60448540d46a5372c26ad7efa
|
14574d374fd8907d8a8e339e25e3b0bbfe8303e3
|
/src/main/java/org/example/enums/Permission.java
|
1fbf5d08787abf87835128548580383443992cb8
|
[] |
no_license
|
mKostsov24/graduation_project
|
b5c790aa053c1a745ed7ab492b0f3cc32282fff4
|
62fa83344d45d54d971875411a3ac3ade7b65a3a
|
refs/heads/master
| 2023-08-16T05:32:22.039091
| 2021-10-11T16:31:10
| 2021-10-11T16:31:10
| 366,181,716
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 293
|
java
|
package org.example.enums;
public enum Permission {
USER("user:write"),
MODER("user:moder");
private final String permission;
Permission(String permission) {
this.permission = permission;
}
public String getPermission() {
return permission;
}
}
|
[
"dubok24@yandex.ru"
] |
dubok24@yandex.ru
|
a420caf2aed130c29a05df539f0eba819e92c67a
|
fb71f4802819b0f9e5eb2f71bfe356258b8d1f57
|
/ontrack-ui-support/src/main/java/net/nemerosa/ontrack/ui/resource/ResourceDecorationContributorServiceImpl.java
|
3c72f1504819f7247e52325492d2ee1d022f53da
|
[
"MIT"
] |
permissive
|
nemerosa/ontrack
|
c5abe0556cc2cc6eb4109e0c2f045ae5cff84da3
|
de5ae2ebd9d9a30dce4c717f57e4604da85f0b51
|
refs/heads/master
| 2023-08-31T11:02:35.297467
| 2023-08-28T17:59:07
| 2023-08-28T17:59:07
| 19,351,480
| 111
| 35
|
MIT
| 2023-08-31T13:21:53
| 2014-05-01T17:08:33
|
Kotlin
|
UTF-8
|
Java
| false
| false
| 2,497
|
java
|
package net.nemerosa.ontrack.ui.resource;
import net.nemerosa.ontrack.model.structure.NameDescription;
import net.nemerosa.ontrack.model.structure.ProjectEntity;
import net.nemerosa.ontrack.model.structure.ProjectEntityType;
import net.nemerosa.ontrack.model.support.ApplicationLogEntry;
import net.nemerosa.ontrack.model.support.ApplicationLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@Service
public class ResourceDecorationContributorServiceImpl implements ResourceDecorationContributorService {
private final ApplicationLogService logService;
private final Collection<ResourceDecorationContributor> contributors;
@Autowired
public ResourceDecorationContributorServiceImpl(ApplicationLogService logService, Collection<ResourceDecorationContributor> contributors) {
this.logService = logService;
this.contributors = contributors;
}
@Override
public <T extends ProjectEntity> List<LinkDefinition<T>> getLinkDefinitions(ProjectEntityType projectEntityType) {
List<LinkDefinition<T>> definitions = new ArrayList<>();
contributors.forEach(contributor -> {
if (contributor.applyTo(projectEntityType)) {
try {
@SuppressWarnings("unchecked")
ResourceDecorationContributor<T> tResourceDecorationContributor = (ResourceDecorationContributor<T>) contributor;
definitions.addAll(tResourceDecorationContributor.getLinkDefinitions());
} catch (Exception ex) {
// Logging
logService.log(
ApplicationLogEntry.fatal(
ex,
NameDescription.nd(
"ui-resource-decoration",
"Issue when collecting UI resource decoration"
),
contributor.getClass().getName()
)
.withDetail("ui-resource-type", projectEntityType.name())
.withDetail("ui-resource-decorator", contributor.getClass().getName())
);
}
}
});
return definitions;
}
}
|
[
"damien.coraboeuf@gmail.com"
] |
damien.coraboeuf@gmail.com
|
41236c984220a39d2f481891c48431344b1edf4f
|
0175a417f4b12b80cc79edbcd5b7a83621ee97e5
|
/flexodesktop/GUI/flexo/src/main/java/org/openflexo/components/OpenProjectComponent.java
|
1fe941bbf3dbe6ba724e1091f3faa49180314cb2
|
[] |
no_license
|
agilebirds/openflexo
|
c1ea42996887a4a171e81ddbd55c7c1e857cbad0
|
0250fc1061e7ae86c9d51a6f385878df915db20b
|
refs/heads/master
| 2022-08-06T05:42:04.617144
| 2013-05-24T13:15:58
| 2013-05-24T13:15:58
| 2,372,131
| 11
| 6
| null | 2022-07-06T19:59:55
| 2011-09-12T15:44:45
|
Java
|
UTF-8
|
Java
| false
| false
| 2,311
|
java
|
/*
* (c) Copyright 2010-2011 AgileBirds
*
* This file is part of OpenFlexo.
*
* OpenFlexo is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenFlexo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenFlexo. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.openflexo.components;
import java.awt.Frame;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import org.openflexo.AdvancedPrefs;
import org.openflexo.prefs.FlexoPreferences;
import org.openflexo.view.FlexoFrame;
/**
* Component allowing to choose an existing flexo project
*
* @author sguerin
*/
public class OpenProjectComponent extends ProjectChooserComponent {
private static final Logger logger = Logger.getLogger(OpenProjectComponent.class.getPackage().getName());
protected OpenProjectComponent(Frame owner) {
super(owner);
logger.info("Build OpenProjectComponent");
}
public static File getProjectDirectory() {
return getProjectDirectory(FlexoFrame.getActiveFrame());
}
public static File getProjectDirectory(Frame owner) {
OpenProjectComponent chooser = new OpenProjectComponent(owner);
File returned = null;
int returnVal = -1;
boolean ok = false;
while (!ok) {
try {
returnVal = chooser.showOpenDialog();
ok = true;
} catch (ArrayIndexOutOfBoundsException e) {
if (logger.isLoggable(Level.WARNING)) {
logger.warning("Caught ArrayIndexOutOfBoundsException, hope this will stop");
}
}
}
if (returnVal == JFileChooser.APPROVE_OPTION) {
returned = chooser.getSelectedFile();
AdvancedPrefs.setLastVisitedDirectory(returned.getParentFile());
FlexoPreferences.savePreferences(true);
} else {
if (logger.isLoggable(Level.FINE)) {
logger.fine("No project supplied");
}
return null;
}
return returned;
}
}
|
[
"guillaume.polet@gmail.com"
] |
guillaume.polet@gmail.com
|
3c352228b6300d01263227363df0c09402bd0a37
|
c381f5be286e80336ada8968ad17593b1c59ff49
|
/NumberShapes/src/NumberShape.java
|
8ad03a8dd28c90cacb5cefddfc1917b41d7b3713
|
[] |
no_license
|
nagesh1805/NumberShapes
|
ff2078122b23cb38ac5c7b8dba30902d3437ab6b
|
cb2b737cdb4b0d900de9eef08056bd19e3112e56
|
refs/heads/master
| 2023-06-16T11:51:40.247184
| 2021-07-15T21:58:09
| 2021-07-15T21:58:09
| 381,561,298
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,346
|
java
|
import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.net.URL;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import acm.graphics.*;
import acm.gui.IntField;
import acm.io.IODialog;
import acm.program.*;
import acm.util.RandomGenerator;
public class NumberShape extends GraphicsProgram {
public void init() {
setSize(APPLICATION_WIDTH,APPLICATION_HEIGHT);
setBackground(Color.BLACK);
// soundClip.loop();
addKeyListeners();
addActionListeners();
}
private static int gcd(int a, int b) {
int k=1;
int m=(a<b)?a:b;
for (int i=2; i<=m;i++) {
if ((a%i==0)&&(b%i==0)) {
k=i;
}
}
return k;
}
public void run(){
//soundClip = getAudioClip(getDocumentBase(),"titanic_theme.wav");
soundClipURL= getClass().getResource("titanic_theme.wav");
soundClip=Applet.newAudioClip(soundClipURL);
soundClip.loop();
double[] fl=new double[100];
comp = new NumShapeComponent(SIZE);
add(comp);
pause(1000);
for(int k=0;k<SIZE;k++) {
int g,numrtr,dnmntr;
do {
numrtr=gen.nextInt(1,30);
dnmntr=gen.nextInt(1,30);
g=gcd(numrtr,dnmntr);
numrtr=numrtr/g;
dnmntr=dnmntr/g;
}while(containf(fl,numrtr*(1.0)/dnmntr));
// comp.setFlbl(numrtr+"/"+dnmntr,k);
comp.drawNumberShape(numrtr,dnmntr,1000,k);
fl[k]=numrtr/dnmntr;
pause(50);
}
soundClip.stop();
}
private boolean containf(double[] l,double d) {
for (int k=0;k<l.length;k++) {
if (l[k]==d) {
return true;
}
}
return false;
}
private NumShapeComponent comp;
private static final int APPLICATION_WIDTH=1280;
private static final int APPLICATION_HEIGHT=800;
private static final double PI=3.141592;
private AudioClip soundClip;
private URL soundClipURL;
private RandomGenerator gen=RandomGenerator.getInstance();
public static final int SIZE=20;
}
|
[
"nageshmath@gmail.com"
] |
nageshmath@gmail.com
|
0260cb5f8cee6ed686bad748d0c1bac64c6fed3d
|
a2df6764e9f4350e0d9184efadb6c92c40d40212
|
/aliyun-java-sdk-rds/src/main/java/com/aliyuncs/rds/model/v20140815/DescribeInstanceKeywordsRequest.java
|
6c40fa80c899c025de528dcf6c9379a928f94f82
|
[
"Apache-2.0"
] |
permissive
|
warriorsZXX/aliyun-openapi-java-sdk
|
567840c4bdd438d43be6bd21edde86585cd6274a
|
f8fd2b81a5f2cd46b1e31974ff6a7afed111a245
|
refs/heads/master
| 2022-12-06T15:45:20.418475
| 2020-08-20T08:37:31
| 2020-08-26T06:17:49
| 290,450,773
| 1
| 0
|
NOASSERTION
| 2020-08-26T09:15:48
| 2020-08-26T09:15:47
| null |
UTF-8
|
Java
| false
| false
| 2,805
|
java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.rds.model.v20140815;
import com.aliyuncs.RpcAcsRequest;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.rds.Endpoint;
/**
* @author auto create
* @version
*/
public class DescribeInstanceKeywordsRequest extends RpcAcsRequest<DescribeInstanceKeywordsResponse> {
private Long resourceOwnerId;
private String resourceOwnerAccount;
private String ownerAccount;
private Long ownerId;
private String key;
public DescribeInstanceKeywordsRequest() {
super("Rds", "2014-08-15", "DescribeInstanceKeywords", "rds");
setMethod(MethodType.POST);
try {
com.aliyuncs.AcsRequest.class.getDeclaredField("productEndpointMap").set(this, Endpoint.endpointMap);
com.aliyuncs.AcsRequest.class.getDeclaredField("productEndpointRegional").set(this, Endpoint.endpointRegionalType);
} catch (Exception e) {}
}
public Long getResourceOwnerId() {
return this.resourceOwnerId;
}
public void setResourceOwnerId(Long resourceOwnerId) {
this.resourceOwnerId = resourceOwnerId;
if(resourceOwnerId != null){
putQueryParameter("ResourceOwnerId", resourceOwnerId.toString());
}
}
public String getResourceOwnerAccount() {
return this.resourceOwnerAccount;
}
public void setResourceOwnerAccount(String resourceOwnerAccount) {
this.resourceOwnerAccount = resourceOwnerAccount;
if(resourceOwnerAccount != null){
putQueryParameter("ResourceOwnerAccount", resourceOwnerAccount);
}
}
public String getOwnerAccount() {
return this.ownerAccount;
}
public void setOwnerAccount(String ownerAccount) {
this.ownerAccount = ownerAccount;
if(ownerAccount != null){
putQueryParameter("OwnerAccount", ownerAccount);
}
}
public Long getOwnerId() {
return this.ownerId;
}
public void setOwnerId(Long ownerId) {
this.ownerId = ownerId;
if(ownerId != null){
putQueryParameter("OwnerId", ownerId.toString());
}
}
public String getKey() {
return this.key;
}
public void setKey(String key) {
this.key = key;
if(key != null){
putQueryParameter("Key", key);
}
}
@Override
public Class<DescribeInstanceKeywordsResponse> getResponseClass() {
return DescribeInstanceKeywordsResponse.class;
}
}
|
[
"sdk-team@alibabacloud.com"
] |
sdk-team@alibabacloud.com
|
b96e2c590b8aef17f61cc139aced4d6197080a10
|
aed8ff67a899f53cbefc33eef5e4bd158e6997fe
|
/BCGameJam2018Resolution/feature/src/main/java/com/bcgamejam2018/resolution/bcgamejam2018resolution/feature/EndingActivity.java
|
baea1692a965aa39ca12f7cd1448b88197028da1
|
[
"MIT"
] |
permissive
|
kessris/New-Year-s-Resolution
|
d62ab55a2a8ccff85b0ec4bd6417f61f33d700c9
|
2d568ddf0f900f2b5aff7b51c0a997e6f8c44bb6
|
refs/heads/master
| 2021-04-30T06:54:38.904347
| 2018-02-14T01:44:56
| 2018-02-14T01:44:56
| 121,458,116
| 3
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,317
|
java
|
package com.bcgamejam2018.resolution.bcgamejam2018resolution.feature;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.content.Intent;
import java.util.ArrayList;
public class EndingActivity extends AppCompatActivity {
ImageButton btn;
int intelligence = 5;
int wealth = 5;
int relationship = 5;
int health = 5;
int highest = 0;
int hightestStat = 0;
int[] statArray = new int[4];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ending);
Intent intent = getIntent();
intelligence = intent.getIntExtra("intelligence", 5);
wealth = intent.getIntExtra("wealth", 5);
relationship = intent.getIntExtra("relationship", 5);
health = intent.getIntExtra("health", 5);
statArray[0] = intelligence;
statArray[1] = wealth;
statArray[2] = relationship;
statArray[3] = health;
btn = findViewById(R.id.resultImageButton);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
//fail ending
if(intelligence < 75 && wealth < 75 && relationship < 75 && health < 75){
btn.setBackgroundResource(R.drawable.fail_ending);
}else{
for(int i = 1; i < 4; i++){
if(statArray[i] > statArray[hightestStat]){
hightestStat = i;
}
}
switch (hightestStat){
case 0 :
btn.setBackgroundResource(R.drawable.intelligence_ending);
break;
case 1 :
btn.setBackgroundResource(R.drawable.wealth_ending);
break;
case 2 :
btn.setBackgroundResource(R.drawable.relationship_ending);
break;
case 3 :
btn.setBackgroundResource(R.drawable.health_ending);
break;
}
}
}
}
|
[
"noreply@github.com"
] |
kessris.noreply@github.com
|
90bec1c8ee38c9ed848150f61d87fb58fd674e51
|
54552ef1323a9d757c8b4867ed5eddd70252da90
|
/src/main/java/com/example/james/wordsearch/WordDB.java
|
95e1e3f21c7fed489bc23cac5dc774b77bcb01ca
|
[] |
no_license
|
jamesover87/wordSearch3
|
f017670e6095781132d701a5c919d95ba9e51692
|
74495d868e2d33c365dd5dd49ead3382179677c3
|
refs/heads/master
| 2021-01-17T12:59:05.529555
| 2016-08-07T21:02:14
| 2016-08-07T21:02:14
| 65,153,899
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 41,245
|
java
|
package com.example.james.wordsearch;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import android.content.ContentValues;
import android.content.Context;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
/**
* Created by James on 8/1/2016.
*/
public class WordDB {
// database constants
public static final String DB_NAME = "word.db";
public static final int DB_VERSION = 1;
// word table constants
public static final String WORD_TABLE = "word";
public static final String WORD_ID = "_id";
public static final int WORD_ID_COL = 0;
public static final String WORD_NAME = "word_name";
public static final int WORD_NAME_COL = 1;
public static final String WORD_DEFINITION = "word_definition";
public static final int WORD_DEFINITION_COL = 2;
public static final String WORD_OTHER = "word_other";
public static final int WORD_OTHER_COL = 3;
// database object and database helper object
private SQLiteDatabase db;
private DBHelper dbHelper;
// constructor
public WordDB(Context context){
dbHelper = new DBHelper (context, DB_NAME, null, DB_VERSION);
}
// CREATE and DROP table statements
public static final String CREATE_WORD_TABLE =
"CREATE TABLE " + WORD_TABLE + " (" +
WORD_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
WORD_NAME + " TEXT NOT NULL, " +
WORD_DEFINITION + " TEXT, " +
WORD_OTHER + " TEXT);";
public static final String DROP_WORD_TABLE =
"DROP TABLE IF EXISTS " + WORD_TABLE;
//private static class DBHelper extends SQLiteOpenHelper {
private class DBHelper extends SQLiteOpenHelper {
public DBHelper(Context context, String name, CursorFactory factory, int version){
super(context, name, factory, version);
}
@Override
public void onCreate(SQLiteDatabase db){
db.execSQL(CREATE_WORD_TABLE);
Log.d("word search", "Inside DBHelper.onCreate");
Log.d("word search", "Inside DBHelper.onCreate calling loadWords");
loadWords(db);
Log.d("word search", "Inside DBHelper.onCreate returned from loadWords");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
Log.d("word search", "Upgrading db from version " + oldVersion + " to " + newVersion);
db.execSQL(WordDB.DROP_WORD_TABLE);
onCreate(db);
}
}
private void openReadableDB(){
db = dbHelper.getReadableDatabase();
}
private void openWritableDB(){
db = dbHelper.getWritableDatabase();
}
private void closeDB(){
if (db != null)
db.close();
}
/*
This method returns all words in the database.
It's not actually used by the program and should
probably be removed later, but I'll leave it in
for now.
*/
public ArrayList<Word> getWords(){
this.openReadableDB();
Cursor cursor = db.query(WORD_TABLE, null, null, null, null, null,null);
ArrayList<Word> words = new ArrayList<Word>();
while (cursor.moveToNext()){
Word word = new Word();
word.setId(cursor.getInt(WORD_ID_COL));
word.setName(cursor.getString(WORD_NAME_COL));
word.setDefinition(cursor.getString(WORD_DEFINITION_COL));
word.setOther(cursor.getString(WORD_OTHER_COL));
words.add(word);
}
if(cursor != null)
cursor.close();
this.closeDB();
return words;
}
/*
Searches the database using the wordSearch string provided by
the search method in the MainActivity class. Uses a LIKE operator
in the WHERE clause to find matching words and returns them
as an ArrayList.
*/
public ArrayList<Word> searchWords(String wordSearch){
String where =
WORD_NAME + " LIKE ?";
String[] whereArgs = {wordSearch};
this.openReadableDB();
Cursor cursor = db.query(WORD_TABLE, null, where, whereArgs, null, null,null);
ArrayList<Word> words = new ArrayList<Word>();
while (cursor.moveToNext()){
Word word = new Word();
word.setId(cursor.getInt(WORD_ID_COL));
word.setName(cursor.getString(WORD_NAME_COL));
word.setDefinition(cursor.getString(WORD_DEFINITION_COL));
word.setOther(cursor.getString(WORD_OTHER_COL));
words.add(word);
}
if(cursor != null)
cursor.close();
this.closeDB();
return words;
}
//private static void loadWords(SQLiteDatabase db) {
//private void loadWords(SQLiteDatabase db) throws IOException {
private void loadWords(SQLiteDatabase db) {
Log.d("word search", "Inside loadWords");
/*
// AssetManager stuff may have to happen inside the Activity
AssetManager assetManager = this.getAssets();
//assetManager.getAssets();
try {
//InputStream in = getClass().getResourceAsStream("/1.txt");
//BufferedReader input = new BufferedReader(new InputStreamReader(in));
//InputStream is = getClass().getResourceAsStream("/testWordInserts.txt");
InputStream is = getClass().getResourceAsStream("/com/example/james/wordsearch/WordDB/testWordInserts.txt");
Log.d("word search", "loadWords - is initialized");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
//InputStreamReader isr = new InputStreamReader(is);
//Log.d("word search", "loadWords - isr initialized");
//BufferedReader br = new BufferedReader(isr);
Log.d("word search", "loadWords - br initialized");
String line;
while ((line = br.readLine()) != null) {
//db.execSQL(line);
Log.d("word search", line);
}
br.close();
//isr.close();
is.close();
}
catch (Exception e)
{
// log this
Log.d("word search", "Something went wrong in loadWords");
}
*/
/* plan B test data */
db.execSQL("INSERT INTO word VALUES (NULL, 'absorption', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'achieve', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'adjectives', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'aerating', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'agrarian', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'aleut', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'alphonse', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'amoebic', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'aneurysms', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'anthers', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'apogees', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'aquatint', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'arminius', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'aspell', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'athabasca', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'aureola', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'awls', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'badgering', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'banged', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'barred', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'bazookas', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'beetling', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'benefactresses', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'beulah', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'biodegrade', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'blame', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'bloodletting', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'bode', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'booklets', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'bow', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'breadboard', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'bristling', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'bubo', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'bunged', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'butterballs', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'calaboose', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'canalizes', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'capsulizes', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'carpel', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'catastrophic', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'celandine', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'chaise', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'chaster', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'chicory', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'choppiest', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'circuity', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'clawed', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'clothesline', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'coconuts', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'collegian', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'commingles', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'compositions', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'condoms', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'conjunctions', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'consulates', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'convectors', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'corduroy', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'cosset', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'cousins', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'crayfish', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'croat', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'cryptographer', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'curtailed', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'dainty', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'davids', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'decca', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'defalcated', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'deleting', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'demurest', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'derailing', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'detained', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'dianne', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'dimmer', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'disbursements', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'disharmony', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'disquisitions', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'divesting', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'domestication', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'dowdies', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'drew', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'duisburg', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'earldom', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'eduardo', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'electorate', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'embattled', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'encamps', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'enhancing', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'enuresis', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'eris', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'ethologist', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'examiners', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'exorbitantly', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'exteriors', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'fades', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'fascinates', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'felicitate', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'fiduciary', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'firelighters', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'flashcubes', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'floral', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'folios', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'foreshadowing', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'fox', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'frequents', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'fslic', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'futzing', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'gantry', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'geared', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'gershwin', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'gizzard', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'glycogen', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'gored', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'grapevines', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'grinders', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'guarantees', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'guzman', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'hallowing', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'hardball', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'havoline', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'heavyweight', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'heralding', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'hightailed', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'hoggishly', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'honoree', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'hothouses', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'humiliated', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'hyper', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'igloos', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'impairs', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'impressionability', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'includes', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'indiscretion', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'infinitely', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'innards', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'instinct', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'interlocutors', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'introspective', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'ironwood', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'jackknife', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'jeopardizing', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'jollily', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'jurisdiction', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'kerfuffles', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'kirk', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'krauts', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'lamer', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'laterals', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'leapt', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'leonardo', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'liege', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'lintiest', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'lobby', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'looting', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'ludicrousness', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'macaws', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'mainlands', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'mandrills', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'maria', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'massing', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'mccain', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'melbourne', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'merton', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'microelectronic', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'milquetoast', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'miscalling', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'mistassini', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'molders', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'montessori', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'motifs', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'muhammadanism', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'muskox', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'napoleonic', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'necromancy', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'newbies', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'nissan', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'noninvasive', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'nostalgically', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'nutmeg', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'obtruding', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'oinks', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'opportune', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'orthographic', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'outpatients', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'overdress', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'overspreads', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'pagination', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'pantheon', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'parlays', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'paternally', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'pectic', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'pentagrams', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'permissions', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'petunia', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'phototypesetting', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'pillsbury', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'placebo', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'plenipotentiaries', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'poisson', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'poo', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'postman', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'prc', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'premiering', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'prevaricated', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'procreated', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'proof', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'provided', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'pulitzer', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'pushkin', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'quarto', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'racetrack', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'rams', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'ravened', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'reassuring', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'recommendable', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'redeveloped', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'refinish', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'rehang', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'relining', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'reorganization', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'repurchased', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'respray', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'retrogrades', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'rfd', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'rinses', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'roguery', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'roughnecks', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'runabout', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'said', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'sandpaper', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'savored', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'schisms', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'scram', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'scythia', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'seesaws', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'sentimental', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'sexology', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'sheep', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'shodden', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'shuffled', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'silicons', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'sizzlers', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'slate', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'slovaks', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'snacking', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'snuffly', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'some', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'southwests', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'speedboat', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'splines', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'sputnik', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'stalk', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'steamfitting', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'stinkbug', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'strains', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'stubbiest', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'subordination', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'suggested', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'superintendent', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'survives', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'swine', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'tabby', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'tampons', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'tauten', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'telephotography', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'terran', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'thermally', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'throwbacks', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'timmy', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'toggled', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'tors', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'traffics', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'transportation', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'tricky', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'trudged', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'turgidly', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'typhoon', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'unbiassed', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'underclassmen', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'unenlightened', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'uninstall', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'unpolluted', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'unstraps', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'uprooting', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'vagrants', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'vegetates', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'veterinarians', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'virgule', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'vomiting', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'wallowing', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'waterfalls', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'weepings', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'whiled', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'wifi', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'winters', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'woodsier', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'wriggled', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'yearns', 'Word definition here', 'Other word info here')");
db.execSQL("INSERT INTO word VALUES (NULL, 'zephyr', 'Word definition here', 'Other word info here')");
/* */
}
}
|
[
"noreply@github.com"
] |
jamesover87.noreply@github.com
|
1a05872e83d2903ff5b01f8e7c923a2e6c22ef5c
|
7f20b1bddf9f48108a43a9922433b141fac66a6d
|
/core3/support/tags/support-parent-3.0.0-alpha6/taglets/src/main/java/org/cytoscape/taglets/compatibility/AbstractApiTaglet.java
|
263d1c36f79eb62045516f630068611210cf156b
|
[] |
no_license
|
ahdahddl/cytoscape
|
bf783d44cddda313a5b3563ea746b07f38173022
|
a3df8f63dba4ec49942027c91ecac6efa920c195
|
refs/heads/master
| 2020-06-26T16:48:19.791722
| 2013-08-28T04:08:31
| 2013-08-28T04:08:31
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 3,353
|
java
|
package org.cytoscape.taglets.compatibility;
import com.sun.tools.doclets.Taglet;
import com.sun.javadoc.Tag;
import java.util.Map;
/**
* An abstract taglet for specifying the Cytoscape API documentation
* taglet.
*/
abstract class AbstractApiTaglet implements Taglet {
private final String name;
private final String header;
private final String desc;
/**
* Constructor.
* @param name The name (tag) of the taglet.
* @param header The header for the html output.
* @param desc The description for the html output.
*/
AbstractApiTaglet(String name, String header, String desc) {
this.name = name;
this.header = header;
this.desc = desc;
}
/**
* Returns the name of the taglet found in the javadoc description.
* @return The name of the taglet found in the javadoc description.
*/
public String getName() { return name; }
/**
* Returns false because this taglet should not appear in this context.
* @return false because this taglet should not appear in this context.
*/
public boolean inField() { return false; }
/**
* Returns false because this taglet should not appear in this context.
* @return false because this taglet should not appear in this context.
*/
public boolean inConstructor() { return false; }
/**
* Returns false because this taglet should not appear in this context.
* @return false because this taglet should not appear in this context.
*/
public boolean inMethod() { return false; }
/**
* Returns false because this taglet should not appear in this context.
* @return false because this taglet should not appear in this context.
*/
public boolean inOverview() { return false; }
/**
* Returns false because this taglet should not appear in this context.
* @return false because this taglet should not appear in this context.
*/
public boolean inPackage() { return false; }
/**
* Returns true because this taglet only appears in the type (class) description.
* @return true because this taglet only appears in the type (class) description.
*/
public boolean inType() { return true; }
/**
* Returns false because this taglet should not appear in this context.
* @return false because this taglet should not appear in this context.
*/
public boolean isInlineTag() { return false; }
/**
* Can be used by children to easily implement register(tagletMap).
*/
@SuppressWarnings("unchecked")
static void registerTaglet(Map tagletMap, Taglet tag) {
if ( tagletMap.containsKey( tag.getName() ) )
tagletMap.remove(tag.getName());
tagletMap.put(tag.getName(), tag);
}
/**
* Actually generates the html included in the javadoc for this tag.
* @return A string of HTML to be inserted into the javadoc.
*/
public String toString(Tag tag) {
String result = "<br/><b>Cytoscape Backwards Compatibility (" + header + ")</b>: " + desc +"<br/>";
if ( tag.text() != null && !tag.text().equals("") )
result += tag.text() + "<br/>";
return result;
}
/**
* Simply calls toString(tag) for tag found and concatenates the result.
* @return A string of HTML to be inserted into the javadoc.
*/
public String toString(Tag[] tags) {
String result = "";
for ( Tag t : tags )
result += toString(t);
return result;
}
}
|
[
"mes@0ecc0d97-ab19-0410-9704-bfe1a75892f5"
] |
mes@0ecc0d97-ab19-0410-9704-bfe1a75892f5
|
7689a5a24db5f28736c231197029c1d1b613b5bd
|
e60fbead478d517698543e7dc76bd105af284935
|
/intranet/src/com/stxnext/management/android/ui/dependencies/PopupItem.java
|
a7a1bd8e6dcc45e23ec1d6256d0f1a5f8d7c0ddb
|
[] |
no_license
|
stxnext/stxnext-intranet-android
|
e8bedf962a993dd382fe774ba334983d75b53d4f
|
a8f387d8da4b7479727d78e457ba01779368b7be
|
refs/heads/master
| 2021-01-22T16:53:22.148313
| 2014-04-16T11:58:53
| 2014-04-16T11:58:53
| 13,984,374
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,003
|
java
|
package com.stxnext.management.android.ui.dependencies;
import android.view.View;
import com.stxnext.management.android.R;
public class PopupItem {
private String titleText;
private Object content;
private View layout;
private boolean selected;
public PopupItem(String titleText, Object content) {
super();
this.titleText = titleText;
this.content = content;
}
public View getLayout() {
return layout;
}
public void setLayout(View layout) {
this.layout = layout;
}
public String getTitleText() {
return titleText;
}
public Object getContent() {
return content;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
if(layout!=null){
View v = layout.findViewById(R.id.checkmark);
v.setVisibility(selected?View.VISIBLE:View.INVISIBLE);
}
}
}
|
[
"pawel.luczak@stxnext.pl"
] |
pawel.luczak@stxnext.pl
|
b0853183cabfbf84047b3837dabae6e1a2b12f4a
|
9b901d84169b032b48cf0f4f4f200b4bb6f64fe4
|
/struts/src/com/helloweenvsfei/struts/action/DispatchAction.java
|
abcc037d388970afb52e619855f6fba7098554a0
|
[] |
no_license
|
a0248327/JavaBuch
|
9160ae2342e2f96d5a41e51ae44939c3fb6d0594
|
83b64a6314df0f2932e0feafc2b7ddbae86e0a4a
|
refs/heads/master
| 2016-09-07T18:41:58.357977
| 2015-03-11T13:43:48
| 2015-03-11T13:43:48
| 29,740,865
| 0
| 0
| null | null | null | null |
GB18030
|
Java
| false
| false
| 1,935
|
java
|
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.helloweenvsfei.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/**
* MyEclipse Struts Creation date: 05-03-2008
*
* XDoclet definition:
*
* @struts.action path="/dispatch" name="dispatchForm"
* input="/form/dispatch.jsp" parameter="action" scope="request"
* validate="true"
*/
public class DispatchAction extends org.apache.struts.actions.DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
*
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws Exception
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// 一定要执行这句代码, 父类会利用反射调用相关方法
return super.execute(mapping, form, request, response);
}
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
response.getWriter().println("执行了 add() 方法");
return null;
}
public ActionForward view(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
response.getWriter().println("执行了 view() 方法");
return null;
}
public ActionForward list(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
response.getWriter().println("执行了 list() 方法");
return null;
}
}
|
[
"muxin_email@hotmail.com"
] |
muxin_email@hotmail.com
|
25bfaa9281c3f8109ec560d69eb437c4a1be3f65
|
44898589036c36664fb6ebabadae69910ee0206a
|
/src/Suspended.java
|
877967394539c6e1cd9d2eb01184cedf805e1c11
|
[] |
no_license
|
SSP16SCM59S/Model-Driven-Architecture
|
c1419cabbbc27192853e9c26b9f9fba2635d21a3
|
2b9397902ab0ac212fc81236e5e7e81bf75d2d6a
|
refs/heads/master
| 2020-12-24T18:51:04.307957
| 2016-05-03T01:47:26
| 2016-05-03T01:47:26
| 57,872,515
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 407
|
java
|
import java.io.*;
import java.util.*;
public class Suspended extends States {
public Suspended(EFSM e,AbstractFactory a,Datastore d)
{
super(e,a,d);
}
public void close()
{
obj.newState(9);//state is changed to Idle
obj1.close();
}
public void balance()
{
obj1.displayBalance();// Balance is Displayed
}
public void activate()
{
obj.newState(3);//state is changed to Ready
}
}
|
[
"sshanka5@hawk.iit.edu"
] |
sshanka5@hawk.iit.edu
|
c227d43ef8dc09ebf2c70e1cd4e1e1f555da25fe
|
13b13a4fb642b864a7e6204fa054b6b722bc9242
|
/src/main/java/patterns/behavioral/strategy/validate/ValidationStrategy.java
|
7c5e072cc21f31877be5fc5681a2e7bffc5aa44a
|
[] |
no_license
|
FTLturtle/Java-Examples
|
cc5c07f69a8090036123b391196abb6224544d97
|
f2104e7199feeef5ba7f57797974e167bf5e9c56
|
refs/heads/master
| 2020-05-04T03:45:31.789772
| 2019-04-02T20:09:54
| 2019-04-02T20:09:54
| 178,952,777
| 0
| 0
| null | 2019-04-01T21:52:47
| 2019-04-01T21:52:47
| null |
UTF-8
|
Java
| false
| false
| 641
|
java
|
package patterns.behavioral.strategy.validate;
public abstract class ValidationStrategy {
public abstract boolean isValid(CreditCard creditCard);
protected boolean passesLuhn(String ccNumber){
int sum = 0;
boolean alternate = false;
for(int i = ccNumber.length() - 1; i >=0; i--){
int n = Integer.parseInt(ccNumber.substring(i, i + 1));
if(alternate){
n *= 2;
if(n > 9){
n = (n % 10) + 1;
}
}
sum += n;
alternate = !alternate;
}
return (sum % 10 == 0);
}
}
|
[
"froilan.miranda@gmail.com"
] |
froilan.miranda@gmail.com
|
f838c7a4b22951038cdbe75882a6f18f4f8f646a
|
fabcfdebc9c80435d9876626453bf4742185071e
|
/android/src/main/java/com/niki/jpush/IntentPackage.java
|
8e0013b59663cf6b5fd0ae4b690c8c7f891809ef
|
[] |
no_license
|
NikiLee2016/jpush-react-native-helper
|
70bba472541fdb36a62d199c8c2691b2056569f5
|
805f244eb29091f8120ff4975ae145a5565e87c6
|
refs/heads/master
| 2020-04-11T20:56:09.403227
| 2019-02-22T17:56:07
| 2019-02-22T17:56:07
| 162,088,891
| 5
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 696
|
java
|
package com.niki.jpush;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class IntentPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.asList(new NativeModule[]{new IntentModule(reactContext)});
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
}
|
[
"m13296644326@163.com"
] |
m13296644326@163.com
|
4e8c06d80f3735cc5a23f3c0b63ad6a5dc705bdd
|
6732378a0c1dad6d0af758905eb2b5193e403525
|
/src/day2/D2Task2.java
|
ba7f897a2e71e44a91785573ba971386d808f9db
|
[
"MIT"
] |
permissive
|
AirbornePanda/AdventOfCode2017
|
5aa56a30b34f1fe85877c884124f913dd38f0ee8
|
2fe6cce96b719e6a170568720ea36db259249e09
|
refs/heads/master
| 2021-05-01T20:47:19.057495
| 2018-02-15T22:40:22
| 2018-02-15T22:40:22
| 120,965,418
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,645
|
java
|
package day2;
import util.InputReader;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Arrays;
public class D2Task2 {
public static void main(String[] args) throws IOException, URISyntaxException {
final long startTime = System.currentTimeMillis();
int[][] input = InputReader.readInputTo2dArray("day2/input");
final long fileReaderEndTime = System.currentTimeMillis();
final Integer[] sum = {0};
Arrays.stream(input).forEach(
line -> {
Integer i = 0;
Boolean found = false;
while (i < line.length && !found) {
for (int entry : line) {
if (line[i] != entry && line[i] > entry) {
if (line[i] % entry == 0) {
found = true;
sum[0] += line[i] / entry;
}
}
}
i++;
}
}
);
final long endTime = System.currentTimeMillis();
System.out.println();
System.out.println("Total sum: " + sum[0]);
System.out.println();
System.out.println("Process took: " + (endTime - startTime) + "ms");
System.out.println("With the following tasks");
System.out.println();
System.out.println("Filereader: " + (fileReaderEndTime - startTime) + "ms");
System.out.println("Calculation: " + (endTime - fileReaderEndTime) + "ms");
}
}
|
[
"julian.sauer@outlook.com"
] |
julian.sauer@outlook.com
|
2120efa27b16f0ee3020001b37bd9c2572768746
|
54d7e285c794534f480bcd402522dffabd4998f9
|
/Runner/src/com/ku/runner/DetectedActivitiesIntentService.java
|
a15a7543a6c31123c130ebba0c946cb89a984ac1
|
[] |
no_license
|
RafflesiaKhan/RunwithRunner
|
09ea01d003ee6387460050c183f14d6e43fb1fe5
|
60e1d6119ccdbb645c5900f59a29d70b22f5cea6
|
refs/heads/main
| 2023-04-19T09:58:30.807304
| 2021-04-29T03:32:18
| 2021-04-29T03:32:18
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 7,334
|
java
|
package com.ku.runner;
import android.annotation.SuppressLint;
import android.app.IntentService;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.TaskStackBuilder;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.NotificationCompat;
import android.util.Log;
import com.google.android.gms.location.ActivityRecognitionResult;
import com.google.android.gms.location.DetectedActivity;
import com.ku.runner.activity.MainActivity;
import java.util.ArrayList;
import java.util.List;
/**
* IntentService for handling incoming intents that are generated as a result of requesting
* activity updates using
* {@link com.google.android.gms.location.ActivityRecognitionApi#requestActivityUpdates}.
*/
public class DetectedActivitiesIntentService extends IntentService {
protected static final String TAG = "activity-detection-intent-service";
public DetectedActivitiesIntentService() {
super(TAG);
}
/**
* Called when a new activity detection update is available.
*/
@Override
protected void onHandleIntent(Intent intent) {
// If the incoming intent contains an update
if (ActivityRecognitionResult.hasResult(intent)) {
// Get the update
ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
// Get the most probable activity
DetectedActivity mostProbableActivity = result.getMostProbableActivity();
// Get the probability that this activity is the the user's actual activity
int confidence = mostProbableActivity.getConfidence();
//Get an integer describing the type of activity
int activityType = mostProbableActivity.getType();
if (activityType == DetectedActivity.ON_FOOT) {
DetectedActivity betterActivity = walkingOrRunning(result.getProbableActivities());
if (null != betterActivity)
mostProbableActivity = betterActivity;
}
activityType = mostProbableActivity.getType();
String activityName = getNameFromType(activityType);
/*
* At this point, you have retrieved all the information
* for the current update. You can display this
* information to the user in a notification, or
* send it to an Activity or Service in a broadcast
* Intent.
*/
showNotification(confidence, activityName);
Log.i(TAG,
"CURRENT ACTIVITY"+ getNameFromType(mostProbableActivity.getType()) + " " + mostProbableActivity.getConfidence() + "%"
);
Intent localIntent = new Intent(Constants.BROADCAST_ACTION);
// Get the list of the probable activities associated with the current state of the
// device. Each activity is associated with a confidence level, which is an int between
// 0 and 100.
ArrayList<DetectedActivity> detectedActivities = (ArrayList) result.getProbableActivities();
// Log each activity.
Log.i(TAG, "activities detected");
for (DetectedActivity da: detectedActivities) {
Log.i(TAG, Constants.getActivityString(
getApplicationContext(),
da.getType()) + " " + da.getConfidence() + "%"
);
}
// Broadcast the list of detected activities.
localIntent.putExtra(Constants.ACTIVITY_EXTRA, detectedActivities);
localIntent.putExtra(Constants.CURRENT_ACTIVITY, activityName);
LocalBroadcastManager.getInstance(this).sendBroadcast(localIntent);
} else {
/*
* This implementation ignores intents that don't contain
* an activity update. If you wish, you can report them as
* errors.
*/
}
}
private DetectedActivity walkingOrRunning(List<DetectedActivity> probableActivities) {
DetectedActivity myActivity = null;
int confidence = 0;
for (DetectedActivity activity : probableActivities) {
if (activity.getType() != DetectedActivity.RUNNING && activity.getType() != DetectedActivity.WALKING)
continue;
if (activity.getConfidence() > confidence)
myActivity = activity;
}
return myActivity;
}
/**
* Map detected activity types to strings
*
* @param activityType The detected activity type
* @return A user-readable name for the type
*/
private String getNameFromType(int activityType) {
switch (activityType) {
case DetectedActivity.IN_VEHICLE:
return "in_vehicle";
case DetectedActivity.ON_BICYCLE:
return "on_bicycle";
case DetectedActivity.ON_FOOT:
return "on_foot";
case DetectedActivity.STILL:
return "still";
case DetectedActivity.UNKNOWN:
return "unknown";
case DetectedActivity.TILTING:
return "tilting";
}
return "unknown";
}
@SuppressLint("NewApi")
private void showNotification(int confidence, String activityName) {
// Create an explicit content Intent that starts the main Activity
Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);
// Construct a task stack
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Adds the main Activity to the task stack as the parent
stackBuilder.addParentStack(MainActivity.class);
// Push the content Intent onto the stack
stackBuilder.addNextIntent(notificationIntent);
// Get a PendingIntent containing the entire back stack
PendingIntent notificationPendingIntent =
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
// Get a notification builder that's compatible with platform versions >= 4
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
// Set the notification contents
builder.setSmallIcon(R.drawable.abc_ab_share_pack_mtrl_alpha) //
.setWhen(System.currentTimeMillis()) //
.setContentTitle("Activity Recognition") // Transition Type
.setContentText("" + confidence + "% of " + activityName) // Zone Name
.setContentIntent(notificationPendingIntent);
// BigView
NotificationCompat.InboxStyle inBoxStyle = new NotificationCompat.InboxStyle();
inBoxStyle.setBigContentTitle("Activity Recognition");
inBoxStyle.addLine("" + confidence + "% of " + activityName);
builder.setStyle(inBoxStyle);
// Get an instance of the Notification manager
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// Issue the notification
mNotificationManager.notify(0, builder.build());
}
}
|
[
"rafflesiakhan.nw@gmail.com"
] |
rafflesiakhan.nw@gmail.com
|
20f8c80673d7de3cb7907df2185bb0e9b0026dc1
|
73154608ecedb7c34b59575c55177929579c4cb3
|
/StudentDetails.java
|
fe97d986665ed1c844cdbf4be69d0a80c1f852f5
|
[] |
no_license
|
parthbathia/Java_Session6Assignment4
|
645b490be27ba2f560da8f0382feb29a436838a6
|
a5963a5fefcf5c9220d24467f30c371ac683d6c9
|
refs/heads/master
| 2021-01-20T19:57:32.647501
| 2016-06-06T07:13:18
| 2016-06-06T07:13:18
| 60,003,871
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 120
|
java
|
public abstract class StudentDetails {
String studentName = null;
int studentRollNo;
int studentRegNo;
}
|
[
"parthbathia@gmail.com"
] |
parthbathia@gmail.com
|
fa21f01b46977d01ab0eedefeff41cc4fd513282
|
21e092f59107e5cceaca12442bc2e90835473c8b
|
/bacore/src/main/java/com/basoft/core/ware/wechat/domain/msg/NewsMsg.java
|
79d86417b6b999de8077969a3af16b9096e22552
|
[] |
no_license
|
kim50012/smart-menu-endpoint
|
55095ac22dd1af0851c04837190b7b6652d884a0
|
d45246f341f315f8810429b3a4ec1d80cb894d7f
|
refs/heads/master
| 2023-06-17T02:52:01.135480
| 2021-07-15T15:05:19
| 2021-07-15T15:05:19
| 381,788,497
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,158
|
java
|
package com.basoft.core.ware.wechat.domain.msg;
import java.util.ArrayList;
import java.util.List;
import net.sf.json.JSONObject;
/**
{
"touser":"OPENID",
"msgtype":"news",
"news":{
"articles": [
{
"title":"Happy Day",
"description":"Is Really A Happy Day",
"url":"URL",
"picurl":"PIC_URL"
},
{
"title":"Happy Day",
"description":"Is Really A Happy Day",
"url":"URL",
"picurl":"PIC_URL"
}
]
}
}
*/
public class NewsMsg {
private String touser = "";
private List<Article> newsList = new ArrayList<Article>();
public static void main(String[] args) {
NewsMsg im = new NewsMsg("touser");
im.getNewsList().add(new Article("1", "2", "3", "4"));
im.getNewsList().add(new Article("1", "2", "3", "4"));
im.getNewsList().add(new Article("1", "2", "3", "4"));
System.out.println(im.toJsonString());
}
public NewsMsg() {
super();
}
public NewsMsg(String touser) {
super();
this.touser = touser;
}
public String getTouser() {
return touser;
}
public void setTouser(String touser) {
this.touser = touser;
}
public List<Article> getNewsList() {
return newsList;
}
public void setNewsList(List<Article> newsList) {
this.newsList = newsList;
}
public JSONObject toJson() {
JSONObject news = new JSONObject();
List<JSONObject> articleList = new ArrayList<JSONObject>();
for (int i = 0; i < newsList.size() && i < 10; i++) {
JSONObject article = new JSONObject();
article.put("title", newsList.get(i).getTitle());
article.put("description", newsList.get(i).getDescription());
article.put("url", newsList.get(i).getUrl());
article.put("picurl", newsList.get(i).getPicurl());
articleList.add(article);
}
JSONObject articles = new JSONObject();
articles.put("articles", articleList);
JSONObject root = new JSONObject();
root.put("touser", touser);
root.put("msgtype", "news");
root.put("news", articles);
return root;
}
public String toJsonString() {
return toJson().toString();
}
}
|
[
"kim50012@naver.com"
] |
kim50012@naver.com
|
717848e72985d96ff40fbd7a083b4dce6d92053f
|
720dd4f50c1e103c9782fd3ad432f8d1f1c31f26
|
/LeetCode/src/KthElement.java
|
1f77a09029d3a3acf0a70e74c55768f1261a1f1b
|
[] |
no_license
|
kwang108/coding
|
a4d934416fb6345035f278e2af5f46f070bce8b0
|
db67ed19061f4c3e63388ed732676a28c7a58629
|
refs/heads/master
| 2020-04-12T23:04:28.165586
| 2014-10-07T01:57:03
| 2014-10-07T01:57:03
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,502
|
java
|
/**
* Created by kkwang on 7/15/14.
*/
public class KthElement {
/**
* Find the k-th Smallest Element in the Union of Two Sorted Arrays A and B.
*
* At index i, there are i elements smaller than A[i]. For example, {1, 3, 5, 7} and i=2, there are two numbers smaller
* than A[2]=5. Similarly, at index j, there are j elements smaller than B[j].
* If A[i] is the kth element in the union of A and B, there must be a total of k-1 elements smaller than A[i].
* And IF B[j-1] < A[i] < B[j], A[i] would be inserted at index j in B and there are j elements in B[j] that are smaller than A[i].
* Therefore, in total there are i+j elements in the union smaller than A[i]. This implies that i+j = k-1
*
* @param A sorted int array
* @param m1 first index of array A
* @param m2 last index of array A
* @param B sorted int array
* @param n1 first index of array B
* @param n2 last index of array B
* @param k
* @return
*/
static int findKthSmallest(int A[], int m1, int m2, int B[], int n1, int n2, int k) {
int i = (m2-m1) / 2; //offset for the middle element
int j = (k-1) - i; // (i + j + 1 = k)
i = i + m1; // array index of the middle element
j = n1 + j; // array index of the middle element
// invariant: i + j = k-1
// Note: A[-1] = -INF and A[m] = +INF to maintain invariant
int Ai_1 = ((i == 0) ? Integer.MIN_VALUE : A[i-1]);
int Bj_1 = ((j == 0) ? Integer.MIN_VALUE : B[j-1]);
int Ai = ((i > m2) ? Integer.MAX_VALUE : A[i]);
int Bj = ((j > n2) ? Integer.MAX_VALUE : B[j]);
if (Bj_1 < Ai && Ai < Bj)
return Ai;
else if (Ai_1 < Bj && Bj < Ai)
return Bj;
// if none of the cases above, then it is either:
if (Ai < Bj)
// exclude Ai and below portion
// exclude Bj and above portion
return findKthSmallest(A, m1+i+1, m2, B, n1, j-1, k-i-1); //Since we are ignoring some elements, k needs to be reduced accordingly.
else /* Bj < Ai */
// exclude Ai and above portion
// exclude Bj and below portion
return findKthSmallest(A, m1, i-1, B, n1+j+1, n2, k-j-1);
}
public static void main(String[] args) {
int[] a = {1, 3, 5};
int[] b = {2, 4, 6, 8};
int result = findKthSmallest(a, 0, a.length-1, b, 0, b.length-1, 5);
System.out.println(result);
}
}
|
[
"kangwang1982@gmail.com"
] |
kangwang1982@gmail.com
|
d115c8f4603a235628ac36043ef97c2d8d4bd292
|
d914b758adb3e069a92dc1cfc0335d0dff1c4eae
|
/magick-core/src/main/java/com/gemserk/games/magick/systems/PhysicsTransformationSystem.java
|
95898235867c080bb50402f27c9f3ca34347b3dc
|
[] |
no_license
|
rgarat/magick
|
347593169af7c0de83f48843aaf2a4352c0a38c0
|
b952cc3b28e4b602db39eee73b1cac8929be7461
|
refs/heads/master
| 2021-01-15T16:15:10.338984
| 2011-05-21T00:49:54
| 2011-05-21T00:49:54
| 1,523,169
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,019
|
java
|
package com.gemserk.games.magick.systems;
import com.artemis.ComponentMapper;
import com.artemis.Entity;
import com.artemis.EntityProcessingSystem;
import com.badlogic.gdx.math.Vector2;
import com.gemserk.artemis.components.ComponentMapperInitHelper;
import com.gemserk.games.magick.components.BodyComponent;
import com.gemserk.games.magick.components.PositionComponent;
public class PhysicsTransformationSystem extends EntityProcessingSystem {
ComponentMapper<PositionComponent> positionMapper;
ComponentMapper<BodyComponent> bodyMapper;
public PhysicsTransformationSystem() {
super(PositionComponent.class, BodyComponent.class);
}
@Override
protected void process(Entity e) {
PositionComponent positionComponent = positionMapper.get(e);
BodyComponent bodyComponent = bodyMapper.get(e);
Vector2 position = bodyComponent.body.getPosition();
positionComponent.pos.set(position);
}
@Override
public void initialize() {
ComponentMapperInitHelper.config(this, world.getEntityManager());
}
}
|
[
"ruben.garat@gemserk.com"
] |
ruben.garat@gemserk.com
|
20b791b3d6ec4924b72a6d1722433f5b14f34b90
|
7d0ed9cacf4e48baf0aa25d4a8d2de4af6387b33
|
/android/view/accessibility/AccessibilityRecord.java
|
d407a7ca88edc2502903a468f7638b51676d71db
|
[
"Apache-2.0"
] |
permissive
|
yuanliwei/Monkey-Repl
|
fba5a773fcc88c5de48436a5c2529686ece40e33
|
381bd7da3591d83628a54ea7d1760712cbe0ad13
|
refs/heads/master
| 2022-07-05T09:45:17.077556
| 2022-06-24T01:16:40
| 2022-06-24T01:16:40
| 195,626,675
| 7
| 3
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 6,534
|
java
|
package android.view.accessibility;
import java.util.ArrayList;
import java.util.List;
import android.os.Parcelable;
import android.view.View;
public class AccessibilityRecord {
protected static final boolean DEBUG_CONCISE_TOSTRING = false;
boolean mSealed;
int mBooleanProperties = 0;
long mSourceNodeId = AccessibilityNodeInfo.UNDEFINED_NODE_ID;
int mSourceWindowId = AccessibilityWindowInfo.UNDEFINED_WINDOW_ID;
CharSequence mClassName;
CharSequence mContentDescription;
CharSequence mBeforeText;
Parcelable mParcelableData;
final List<CharSequence> mText = new ArrayList<CharSequence>();
AccessibilityRecord() {
throw new RuntimeException("Stub!");
}
public void setSource(View source) {
throw new RuntimeException("Stub!");
}
public void setWindowId(int windowId) {
throw new RuntimeException("Stub!");
}
public int getWindowId() {
throw new RuntimeException("Stub!");
}
public boolean isChecked() {
throw new RuntimeException("Stub!");
}
public void setChecked(boolean isChecked) {
throw new RuntimeException("Stub!");
}
public boolean isEnabled() {
throw new RuntimeException("Stub!");
}
public void setEnabled(boolean isEnabled) {
throw new RuntimeException("Stub!");
}
public boolean isPassword() {
throw new RuntimeException("Stub!");
}
public void setPassword(boolean isPassword) {
throw new RuntimeException("Stub!");
}
public boolean isFullScreen() {
throw new RuntimeException("Stub!");
}
public void setFullScreen(boolean isFullScreen) {
throw new RuntimeException("Stub!");
}
public boolean isScrollable() {
throw new RuntimeException("Stub!");
}
public void setScrollable(boolean scrollable) {
throw new RuntimeException("Stub!");
}
public boolean isImportantForAccessibility() {
throw new RuntimeException("Stub!");
}
public void setImportantForAccessibility(boolean importantForAccessibility) {
throw new RuntimeException("Stub!");
}
public int getItemCount() {
throw new RuntimeException("Stub!");
}
public void setItemCount(int itemCount) {
throw new RuntimeException("Stub!");
}
public int getCurrentItemIndex() {
throw new RuntimeException("Stub!");
}
public void setCurrentItemIndex(int currentItemIndex) {
throw new RuntimeException("Stub!");
}
public int getFromIndex() {
throw new RuntimeException("Stub!");
}
public void setFromIndex(int fromIndex) {
throw new RuntimeException("Stub!");
}
public int getToIndex() {
throw new RuntimeException("Stub!");
}
public void setToIndex(int toIndex) {
throw new RuntimeException("Stub!");
}
public int getScrollX() {
throw new RuntimeException("Stub!");
}
public void setScrollX(int scrollX) {
throw new RuntimeException("Stub!");
}
public int getScrollY() {
throw new RuntimeException("Stub!");
}
public void setScrollY(int scrollY) {
throw new RuntimeException("Stub!");
}
public int getScrollDeltaX() {
throw new RuntimeException("Stub!");
}
public void setScrollDeltaX(int scrollDeltaX) {
throw new RuntimeException("Stub!");
}
public int getScrollDeltaY() {
throw new RuntimeException("Stub!");
}
public void setScrollDeltaY(int scrollDeltaY) {
throw new RuntimeException("Stub!");
}
public int getMaxScrollX() {
throw new RuntimeException("Stub!");
}
public void setMaxScrollX(int maxScrollX) {
throw new RuntimeException("Stub!");
}
public int getMaxScrollY() {
throw new RuntimeException("Stub!");
}
public void setMaxScrollY(int maxScrollY) {
throw new RuntimeException("Stub!");
}
public int getAddedCount() {
throw new RuntimeException("Stub!");
}
public void setAddedCount(int addedCount) {
throw new RuntimeException("Stub!");
}
public int getRemovedCount() {
throw new RuntimeException("Stub!");
}
public void setRemovedCount(int removedCount) {
throw new RuntimeException("Stub!");
}
public CharSequence getClassName() {
throw new RuntimeException("Stub!");
}
public void setClassName(CharSequence className) {
throw new RuntimeException("Stub!");
}
public List<CharSequence> getText() {
throw new RuntimeException("Stub!");
}
public CharSequence getBeforeText() {
throw new RuntimeException("Stub!");
}
public void setBeforeText(CharSequence beforeText) {
throw new RuntimeException("Stub!");
}
public CharSequence getContentDescription() {
throw new RuntimeException("Stub!");
}
public void setContentDescription(CharSequence contentDescription) {
throw new RuntimeException("Stub!");
}
public Parcelable getParcelableData() {
throw new RuntimeException("Stub!");
}
public void setParcelableData(Parcelable parcelableData) {
throw new RuntimeException("Stub!");
}
public long getSourceNodeId() {
throw new RuntimeException("Stub!");
}
public void setConnectionId(int connectionId) {
throw new RuntimeException("Stub!");
}
public void setSealed(boolean sealed) {
throw new RuntimeException("Stub!");
}
boolean isSealed() {
throw new RuntimeException("Stub!");
}
void enforceSealed() {
throw new RuntimeException("Stub!");
}
void enforceNotSealed() {
throw new RuntimeException("Stub!");
}
public static AccessibilityRecord obtain(AccessibilityRecord record) {
throw new RuntimeException("Stub!");
}
public static AccessibilityRecord obtain() {
throw new RuntimeException("Stub!");
}
public void recycle() {
throw new RuntimeException("Stub!");
}
void init(AccessibilityRecord record) {
throw new RuntimeException("Stub!");
}
void clear() {
throw new RuntimeException("Stub!");
}
@Override
public String toString() {
throw new RuntimeException("Stub!");
}
StringBuilder appendTo(StringBuilder builder) {
throw new RuntimeException("Stub!");
}
}
|
[
"891789592@qq.com"
] |
891789592@qq.com
|
d2eaca3de9af02950ee393d30693c50929ead91c
|
8d15368052fb30921efe82afe3c30f4b9dbc3b80
|
/ex06/src/main/java/com/jzheng/core/SimpleContextLifecycleListener.java
|
a486e87533706cf6913aa7736dbb387a72e7a18d
|
[] |
no_license
|
jack-zheng/how-tomcat-works
|
b68a87caec1e63392c481b5f11deeff75704eb88
|
e068fc29ff69273c43f7b741ca42717f08f249cf
|
refs/heads/main
| 2023-08-11T14:42:41.921957
| 2021-09-20T11:52:54
| 2021-09-20T11:52:54
| 384,414,094
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 784
|
java
|
package com.jzheng.core;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
import java.util.logging.Logger;
public class SimpleContextLifecycleListener implements LifecycleListener {
private final Logger logger = Logger.getLogger(this.getClass().getSimpleName());
public void lifecycleEvent(LifecycleEvent event) {
Lifecycle lifecycle = event.getLifecycle();
System.out.println("SimpleContextLifecycleListener's event " + event.getType());
if (Lifecycle.START_EVENT.equals(event.getType())) {
logger.info("Starting context.");
} else if (Lifecycle.STOP_EVENT.equals(event.getType())) {
logger.info("Stopping context.");
}
}
}
|
[
"jiabin.zheng01@sap.com"
] |
jiabin.zheng01@sap.com
|
a17bc93aa78bf700062305576f7973191721b295
|
0504f6e33b7438183b86a11e62d0bf0e5648df91
|
/src/main/java/com/examples/config/MultipartConfig.java
|
5cc6d06545b98e9074d3c7f3cd7025842afec1dd
|
[] |
no_license
|
designreuse/spr-mvc-java-config
|
83b3ed88d7ccafeaf262d094f55a8cc5a8a2b734
|
24dde1dcca017cca3f6fe612f0cfefc4557f53bd
|
refs/heads/master
| 2020-12-03T00:37:48.267829
| 2015-12-17T17:19:14
| 2015-12-17T17:19:14
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 610
|
java
|
package com.examples.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
@Configuration
public class MultipartConfig {
/**
* The XML equivalent of MultipartResolver
* <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
*
* @return
*/
@Bean
public MultipartResolver multipartResolver() {
return new CommonsMultipartResolver();
}
}
|
[
"mono.chapagai@gmail.com"
] |
mono.chapagai@gmail.com
|
2e3f006b5bc1c9429e8cc571bd867c55a20610c7
|
d44e9604c3383de330e6aaba935b4142d00bce0a
|
/pi4jPro/src/raspi/server/LEDThread.java
|
1067f3457fad65763c7b18329efeff2aa6eec93b
|
[] |
no_license
|
chaj00/raspberry
|
d57e671f0a8099e7c6cbbbcb6d3281adf5ecf391
|
6a8299538ec102da081a08c09bab0bd4eb16fd6f
|
refs/heads/master
| 2020-04-02T03:29:27.047787
| 2016-07-25T04:58:51
| 2016-07-25T04:58:51
| 64,100,612
| 0
| 0
| null | null | null | null |
UHC
|
Java
| false
| false
| 1,636
|
java
|
package raspi.server;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.SocketAddress;
import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;
//접속한 클라이언트가 보내오는 데이터를 읽어서 ledon이라는 값과 일치하는 문자열이 있으면
//pi4j를 이용해서 gpio0번 핀에 연결된 led를 키고 ledoff를 만나면 끄는 일을 하는 쓰레드
public class LEDThread implements Runnable {
private Socket client;
private SocketAddress ip;
final GpioController controller = GpioFactory.getInstance();
final GpioPinDigitalOutput ledpin = controller.provisionDigitalOutputPin(RaspiPin.GPIO_00,"led",PinState.LOW);
public LEDThread(Socket client, SocketAddress ip) {
this.client =client;
this.ip = ip;
}
@Override
public void run() {
try {
InputStream in=client.getInputStream();
OutputStream out = client.getOutputStream();
int ledBufSize =0;
byte[] ledbuf = new byte[50];
while((ledBufSize=in.read(ledbuf))!=-1){
String ledData = new String(ledbuf,0,ledBufSize,"UTF-8");
if(ledData.compareTo("ledon")==0){
ledpin.high();
System.out.println("ledon!");
}
if(ledData.compareTo("ledoff")==0){
ledpin.low();
System.out.println("ledoff");
}
out.write(ledbuf, 0, ledBufSize);
}
} catch (IOException e) {
e.printStackTrace();
}finally{
}
}
}
|
[
"CHA@CHA-PC"
] |
CHA@CHA-PC
|
668ab2668b67be4156ed70faac8b44ff0c727bf1
|
c383e57b000ff3152acf7ae3678d6c7e7bff1ed7
|
/src/main/java/io/github/jaychoufans/cms/service/SystemRolePermissionService.java
|
ea2075bdf0aa7f6c97655060e342b910f814fc14
|
[
"Apache-2.0"
] |
permissive
|
ly641921791/ContentManagementSystem
|
22a15eec3c3e89156699db0eae853eaf18183c4e
|
27677361b4b8a1e25db4103b3fb7c3982833c638
|
refs/heads/master
| 2023-06-26T06:32:25.828835
| 2020-10-19T14:55:15
| 2020-10-19T14:55:15
| 264,962,875
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 255
|
java
|
package io.github.jaychoufans.cms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import io.github.jaychoufans.cms.model.SystemRolePermission;
public interface SystemRolePermissionService extends IService<SystemRolePermission> {
}
|
[
"641921791@qq.com"
] |
641921791@qq.com
|
4a33bfc2b88238c5228eeaad165461cd713430b7
|
22502066dd1ca547f6e7b5de7970ae4e2e9c1349
|
/app/libs/example/com/icbc/api/FundBalancequeryTestV1.java
|
60ba10e1e3c61d28d3e706814c86d0fe5508e6bc
|
[] |
no_license
|
springwindyike/QrcodePay
|
1a1bf7f101ae00bdd609157e712eed792adf3ae0
|
8d17a177e519cd8190c9b237ce637d60de22a530
|
refs/heads/master
| 2022-11-14T17:32:48.481572
| 2020-07-14T00:47:20
| 2020-07-14T00:47:20
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,474
|
java
|
package com.icbc.api;
import org.junit.Test;
import com.icbc.api.internal.util.internal.util.fastjson.JSONObject;
import com.icbc.api.request.FundBalancequeryRequestV1;
import com.icbc.api.request.FundBalancequeryRequestV1.FundBalancequeryRequestV1Biz;
import com.icbc.api.response.FundBalancequeryResponseV1;
public class FundBalancequeryTestV1 {
protected static final String MY_PRIVATE_KEY = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALAWAcPiTMRU906PTdy0ozspX7XptZnkEw2C8R64RDB9BiRFXAj0cU4aTA1MyfmGIlceeVdgJf7OnmvpHnYxjQ7sGxMItPtodrGwA2y8j0AEbHc5pNWU8Hn0zoY9smHS5e+KjSbWv+VNbdnrRFTpDeiJ3+s2E/cKI2CDRbo7cAarAgMBAAECgYABiA933q4APyTvf/uTYdbRmuiEMoYr0nn/8hWayMt/CHdXNWs5gLbDkSL8MqDHFM2TqGYxxlpOPwnNsndbW874QIEKmtH/SSHuVUJSPyDW4B6MazA+/e6Hy0TZg2VAYwkB1IwGJox+OyfWzmbqpQGgs3FvuH9q25cDxkWntWbDcQJBAP2RDXlqx7UKsLfM17uu+ol9UvpdGoNEed+5cpScjFcsB0XzdVdCpp7JLlxR+UZNwr9Wf1V6FbD2kDflqZRBuV8CQQCxxpq7CJUaLHfm2kjmVtaQwDDw1ZKRb/Dm+5MZ67bQbvbXFHCRKkGI4qqNRlKwGhqIAUN8Ynp+9WhrEe0lnxo1AkEA0flSDR9tbPADUtDgPN0zPrN3CTgcAmOsAKXSylmwpWciRrzKiI366DZ0m6KOJ7ew8z0viJrmZ3pmBsO537llRQJAZLrRxZRRV6lGrwmUMN+XaCFeGbgJ+lphN5/oc9F5npShTLEKL1awF23HkZD9HUdNLS76HCp4miNXbQOVSbHi2QJAUw7KSaWENXbCl5c7M43ESo9paHHXHT+/5bmzebq2eoBofn+IFsyJB8Lz5L7WciDK7WvrGC2JEbqwpFhWwCOl/w==";
protected static final String APIGW_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwFgHD4kzEVPdOj03ctKM7KV+16bWZ5BMNgvEeuEQwfQYkRVwI9HFOGkwNTMn5hiJXHnlXYCX+zp5r6R52MY0O7BsTCLT7aHaxsANsvI9ABGx3OaTVlPB59M6GPbJh0uXvio0m1r/lTW3Z60RU6Q3oid/rNhP3CiNgg0W6O3AGqwIDAQAB";
protected static final String APP_ID = "10000000000000002166";
@Test
public void test_cop() throws IcbcApiException {
DefaultIcbcClient client = new DefaultIcbcClient(APP_ID, MY_PRIVATE_KEY, APIGW_PUBLIC_KEY);
FundBalancequeryRequestV1 request = new FundBalancequeryRequestV1();
request.setServiceUrl("http://122.19.61.228:8081/api/fund/V1/balancequery");
FundBalancequeryRequestV1Biz bizContent = new FundBalancequeryRequestV1Biz();
bizContent.setCorpNo("123");
bizContent.setCustNo("456");
bizContent.setCardNo("6212260200029661200");//卡号
bizContent.setFundId("000848");//基金代码
request.setBizContent(bizContent);
FundBalancequeryResponseV1 response = client.execute(request);
System.out.println(response);
System.out.println(JSONObject.toJSONString(response));
if (response.isSuccess()) {
// 业务成功处理
System.out.println(response.getReturnCode());
} else {
// 失败
}
}
}
|
[
"595379642@qq.com"
] |
595379642@qq.com
|
d91a5d1c99d02047d39bb5be2cad43f7c034e60a
|
edfb435ee89eec4875d6405e2de7afac3b2bc648
|
/tags/selenium-2.21/java/client/test/org/openqa/selenium/ExecutingAsyncJavascriptTest.java
|
46ef63e7d1f5fe80f1e1fc3d8f55db16c06f0723
|
[
"Apache-2.0"
] |
permissive
|
Escobita/selenium
|
6c1c78fcf0fb71604e7b07a3259517048e584037
|
f4173df37a79ab6dd6ae3f1489ae0cd6cc7db6f1
|
refs/heads/master
| 2021-01-23T21:01:17.948880
| 2012-12-06T22:47:50
| 2012-12-06T22:47:50
| 8,271,631
| 1
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 14,624
|
java
|
package org.openqa.selenium;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.openqa.selenium.testing.Ignore.Driver.ANDROID;
import static org.openqa.selenium.testing.Ignore.Driver.CHROME;
import static org.openqa.selenium.testing.Ignore.Driver.HTMLUNIT;
import static org.openqa.selenium.testing.Ignore.Driver.IE;
import static org.openqa.selenium.testing.Ignore.Driver.IPHONE;
import static org.openqa.selenium.testing.Ignore.Driver.OPERA;
import static org.openqa.selenium.testing.Ignore.Driver.SELENESE;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.testing.Ignore;
import org.openqa.selenium.testing.JUnit4TestBase;
import org.openqa.selenium.testing.JavascriptEnabled;
import org.openqa.selenium.testing.NeedsLocalEnvironment;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Ignore(value = {IE, IPHONE, OPERA, ANDROID},
reason = "IE: Every test appears to be failing. Opera: not implemented yet")
public class ExecutingAsyncJavascriptTest extends JUnit4TestBase {
private JavascriptExecutor executor;
@Before
public void setUp() throws Exception {
if (driver instanceof JavascriptExecutor) {
executor = (JavascriptExecutor) driver;
}
driver.manage().timeouts().setScriptTimeout(0, TimeUnit.MILLISECONDS);
}
@JavascriptEnabled
@Test
public void shouldNotTimeoutIfCallbackInvokedImmediately() {
driver.get(pages.ajaxyPage);
Object result = executor.executeAsyncScript("arguments[arguments.length - 1](123);");
assertThat(result, instanceOf(Number.class));
assertEquals(123, ((Number) result).intValue());
}
@JavascriptEnabled
@Test
public void shouldBeAbleToReturnJavascriptPrimitivesFromAsyncScripts_NeitherNullNorUndefined() {
driver.get(pages.ajaxyPage);
assertEquals(123, ((Number) executor.executeAsyncScript(
"arguments[arguments.length - 1](123);")).longValue());
assertEquals("abc", executor.executeAsyncScript("arguments[arguments.length - 1]('abc');"));
assertFalse((Boolean) executor.executeAsyncScript("arguments[arguments.length - 1](false);"));
assertTrue((Boolean) executor.executeAsyncScript("arguments[arguments.length - 1](true);"));
}
@JavascriptEnabled
@Test
@Ignore(value = {SELENESE}, reason = "SeleniumRC cannot return null values.")
public void shouldBeAbleToReturnJavascriptPrimitivesFromAsyncScripts_NullAndUndefined() {
driver.get(pages.ajaxyPage);
assertNull(executor.executeAsyncScript("arguments[arguments.length - 1](null)"));
assertNull(executor.executeAsyncScript("arguments[arguments.length - 1]()"));
}
@JavascriptEnabled
@Test
@Ignore(value = {SELENESE}, reason = "Selenium cannot return arrays")
public void shouldBeAbleToReturnAnArrayLiteralFromAnAsyncScript() {
driver.get(pages.ajaxyPage);
Object result = executor.executeAsyncScript("arguments[arguments.length - 1]([]);");
assertNotNull("Expected not to be null!", result);
assertThat(result, instanceOf(List.class));
assertTrue(((List) result).isEmpty());
}
@JavascriptEnabled
@Test
@Ignore(value = {SELENESE}, reason = "Selenium cannot return arrays")
public void shouldBeAbleToReturnAnArrayObjectFromAnAsyncScript() {
driver.get(pages.ajaxyPage);
Object result = executor.executeAsyncScript("arguments[arguments.length - 1](new Array());");
assertNotNull("Expected not to be null!", result);
assertThat(result, instanceOf(List.class));
assertTrue(((List) result).isEmpty());
}
@JavascriptEnabled
@Test
@Ignore(value = {ANDROID, SELENESE},
reason = "Android does not properly handle arrays; Selenium cannot return arrays")
public void shouldBeAbleToReturnArraysOfPrimitivesFromAsyncScripts() {
driver.get(pages.ajaxyPage);
Object result = executor.executeAsyncScript(
"arguments[arguments.length - 1]([null, 123, 'abc', true, false]);");
assertNotNull(result);
assertThat(result, instanceOf(List.class));
Iterator results = ((List) result).iterator();
assertNull(results.next());
assertEquals(123, ((Number) results.next()).longValue());
assertEquals("abc", results.next());
assertTrue((Boolean) results.next());
assertFalse((Boolean) results.next());
assertFalse(results.hasNext());
}
@JavascriptEnabled
@Test
@Ignore(value = SELENESE, reason = "Selenium cannot return elements from scripts")
public void shouldBeAbleToReturnWebElementsFromAsyncScripts() {
driver.get(pages.ajaxyPage);
Object result = executor.executeAsyncScript("arguments[arguments.length - 1](document.body);");
assertThat(result, instanceOf(WebElement.class));
assertEquals("body", ((WebElement) result).getTagName().toLowerCase());
}
@JavascriptEnabled
@Test
@Ignore(value = {ANDROID, SELENESE},
reason = "Android does not properly handle arrays; Selenium cannot return elements")
public void shouldBeAbleToReturnArraysOfWebElementsFromAsyncScripts() {
driver.get(pages.ajaxyPage);
Object result = executor.executeAsyncScript(
"arguments[arguments.length - 1]([document.body, document.body]);");
assertNotNull(result);
assertThat(result, instanceOf(List.class));
List list = (List) result;
assertEquals(2, list.size());
assertThat(list.get(0), instanceOf(WebElement.class));
assertThat(list.get(1), instanceOf(WebElement.class));
assertEquals("body", ((WebElement) list.get(0)).getTagName().toLowerCase());
assertEquals(list.get(0), list.get(1));
}
@JavascriptEnabled
@Test
public void shouldTimeoutIfScriptDoesNotInvokeCallback() {
driver.get(pages.ajaxyPage);
try {
// Script is expected to be async and explicitly callback, so this should timeout.
executor.executeAsyncScript("return 1 + 2;");
fail("Should have thrown a TimeOutException!");
} catch (TimeoutException exception) {
// Do nothing.
}
}
@JavascriptEnabled
@Test
public void shouldTimeoutIfScriptDoesNotInvokeCallbackWithAZeroTimeout() {
driver.get(pages.ajaxyPage);
try {
executor.executeAsyncScript("window.setTimeout(function() {}, 0);");
fail("Should have thrown a TimeOutException!");
} catch (TimeoutException exception) {
// Do nothing.
}
}
@JavascriptEnabled
@Test
public void shouldNotTimeoutIfScriptCallsbackInsideAZeroTimeout() {
driver.get(pages.ajaxyPage);
executor.executeAsyncScript(
"var callback = arguments[arguments.length - 1];" +
"window.setTimeout(function() { callback(123); }, 0)");
}
@JavascriptEnabled
@Test
public void shouldTimeoutIfScriptDoesNotInvokeCallbackWithLongTimeout() {
driver.manage().timeouts().setScriptTimeout(500, TimeUnit.MILLISECONDS);
driver.get(pages.ajaxyPage);
try {
executor.executeAsyncScript(
"var callback = arguments[arguments.length - 1];" +
"window.setTimeout(callback, 1500);");
fail("Should have thrown a TimeOutException!");
} catch (TimeoutException exception) {
// Do nothing.
}
}
@JavascriptEnabled
@Test
public void shouldDetectPageLoadsWhileWaitingOnAnAsyncScriptAndReturnAnError() {
driver.get(pages.ajaxyPage);
driver.manage().timeouts().setScriptTimeout(100, TimeUnit.MILLISECONDS);
try {
executor.executeAsyncScript("window.location = '" + pages.dynamicPage + "';");
fail();
} catch (WebDriverException expected) {
}
}
@JavascriptEnabled
@Test
public void shouldCatchErrorsWhenExecutingInitialScript() {
driver.get(pages.ajaxyPage);
try {
executor.executeAsyncScript("throw Error('you should catch this!');");
fail();
} catch (WebDriverException expected) {
}
}
@Ignore(value = {ANDROID},
reason = "Android: Emulator is too slow and latency causes test to fall out of sync with app;")
@JavascriptEnabled
@Test
public void shouldBeAbleToExecuteAsynchronousScripts() {
driver.get(pages.ajaxyPage);
WebElement typer = driver.findElement(By.name("typer"));
typer.sendKeys("bob");
assertEquals("bob", typer.getAttribute("value"));
driver.findElement(By.id("red")).click();
driver.findElement(By.name("submit")).click();
assertEquals("There should only be 1 DIV at this point, which is used for the butter message",
1, getNumDivElements());
driver.manage().timeouts().setScriptTimeout(15, TimeUnit.SECONDS);
String text = (String) executor.executeAsyncScript(
"var callback = arguments[arguments.length - 1];"
+ "window.registerListener(arguments[arguments.length - 1]);");
assertEquals("bob", text);
assertEquals("", typer.getAttribute("value"));
assertEquals("There should be 1 DIV (for the butter message) + 1 DIV (for the new label)",
2, getNumDivElements());
}
@JavascriptEnabled
@Test
public void shouldBeAbleToPassMultipleArgumentsToAsyncScripts() {
driver.get(pages.ajaxyPage);
Number result = (Number) ((JavascriptExecutor) driver)
.executeAsyncScript("arguments[arguments.length - 1](arguments[0] + arguments[1]);", 1, 2);
assertEquals(3, result.intValue());
}
@JavascriptEnabled
@Test
@NeedsLocalEnvironment(reason = "Relies on timing")
public void shouldBeAbleToMakeXMLHttpRequestsAndWaitForTheResponse() {
String script =
"var url = arguments[0];" +
"var callback = arguments[arguments.length - 1];" +
// Adapted from http://www.quirksmode.org/js/xmlhttp.html
"var XMLHttpFactories = [" +
" function () {return new XMLHttpRequest()}," +
" function () {return new ActiveXObject('Msxml2.XMLHTTP')}," +
" function () {return new ActiveXObject('Msxml3.XMLHTTP')}," +
" function () {return new ActiveXObject('Microsoft.XMLHTTP')}" +
"];" +
"var xhr = false;" +
"while (!xhr && XMLHttpFactories.length) {" +
" try {" +
" xhr = XMLHttpFactories.shift().call();" +
" } catch (e) {}" +
"}" +
"if (!xhr) throw Error('unable to create XHR object');" +
"xhr.open('GET', url, true);" +
"xhr.onreadystatechange = function() {" +
" if (xhr.readyState == 4) callback(xhr.responseText);" +
"};" +
"xhr.send('');"; // empty string to stop firefox 3 from choking
driver.get(pages.ajaxyPage);
driver.manage().timeouts().setScriptTimeout(3, TimeUnit.SECONDS);
String response = (String) ((JavascriptExecutor) driver)
.executeAsyncScript(script, pages.sleepingPage + "?time=2");
assertThat(response.trim(),
equalTo("<html><head><title>Done</title></head><body>Slept for 2s</body></html>"));
}
@JavascriptEnabled
@Test
@Ignore(value = {ANDROID, CHROME, HTMLUNIT, IE, IPHONE, OPERA, SELENESE})
@NeedsLocalEnvironment(reason = "Relies on timing")
public void throwsIfScriptTriggersAlert() {
driver.get(pages.simpleTestPage);
driver.manage().timeouts().setScriptTimeout(5000, TimeUnit.MILLISECONDS);
try {
((JavascriptExecutor)driver).executeAsyncScript("setTimeout(arguments[0], 200) ; setTimeout(function() { window.alert('Look! An alert!'); }, 50);");
fail("Expected UnhandledAlertException");
} catch (UnhandledAlertException expected) {
// Expected exception
}
// Shouldn't throw
driver.getTitle();
}
@JavascriptEnabled
@Test
@Ignore(value = {ANDROID, CHROME, HTMLUNIT, IE, IPHONE, OPERA, SELENESE})
@NeedsLocalEnvironment(reason = "Relies on timing")
public void throwsIfAlertHappensDuringScript() {
driver.get(appServer.whereIs("slowLoadingAlert.html"));
driver.manage().timeouts().setScriptTimeout(5000, TimeUnit.MILLISECONDS);
try {
((JavascriptExecutor)driver).executeAsyncScript("setTimeout(arguments[0], 1000);");
fail("Expected UnhandledAlertException");
} catch (UnhandledAlertException expected) {
//Expected exception
}
// Shouldn't throw
driver.getTitle();
}
@Test
@Ignore(value = {ANDROID, CHROME, HTMLUNIT, IE, IPHONE, OPERA, SELENESE})
@NeedsLocalEnvironment(reason = "Relies on timing")
public void throwsIfScriptTriggersAlertWhichTimesOut() {
driver.get(pages.simpleTestPage);
driver.manage().timeouts().setScriptTimeout(5000, TimeUnit.MILLISECONDS);
try {
((JavascriptExecutor)driver).executeAsyncScript("setTimeout(function() { window.alert('Look! An alert!'); }, 50);");
fail("Expected UnhandledAlertException");
} catch (UnhandledAlertException expected) {
// Expected exception
}
// Shouldn't throw
driver.getTitle();
}
@JavascriptEnabled
@Test
@Ignore(value = {ANDROID, CHROME, HTMLUNIT, IE, IPHONE, OPERA, SELENESE})
@NeedsLocalEnvironment(reason = "Relies on timing")
public void throwsIfAlertHappensDuringScriptWhichTimesOut() {
driver.get(appServer.whereIs("slowLoadingAlert.html"));
driver.manage().timeouts().setScriptTimeout(5000, TimeUnit.MILLISECONDS);
try {
((JavascriptExecutor)driver).executeAsyncScript("");
fail("Expected UnhandledAlertException");
} catch (UnhandledAlertException expected) {
//Expected exception
}
// Shouldn't throw
driver.getTitle();
}
@JavascriptEnabled
@Test
@Ignore(value = {ANDROID, CHROME, HTMLUNIT, IE, IPHONE, OPERA, SELENESE})
@NeedsLocalEnvironment(reason = "Relies on timing")
public void includesAlertInUnhandledAlertException() {
driver.manage().timeouts().setScriptTimeout(5000, TimeUnit.MILLISECONDS);
String alertText = "Look! An alert!";
try {
((JavascriptExecutor)driver).executeAsyncScript("setTimeout(arguments[0], 200) ; setTimeout(function() { window.alert('" + alertText + "'); }, 50);");
fail("Expected UnhandledAlertException");
} catch (UnhandledAlertException e) {
Alert alert = e.getAlert();
assertNotNull(alert);
assertEquals(alertText, alert.getText());
}
}
private long getNumDivElements() {
// Selenium does not support "findElements" yet, so we have to do this through a script.
return (Long) ((JavascriptExecutor) driver).executeScript(
"return document.getElementsByTagName('div').length;");
}
}
|
[
"kristian.rosenvold@gmail.com@07704840-8298-11de-bf8c-fd130f914ac9"
] |
kristian.rosenvold@gmail.com@07704840-8298-11de-bf8c-fd130f914ac9
|
7e318494a5ce4df2466a2ac02e9f9b19294d0e06
|
2fa69fe0521364032aa9c44ec3f0391e94ef8c9f
|
/src/main/java/com/alibaba/Test.java
|
bb44b0a8337d88873a22795d2944820ae482bcb3
|
[] |
no_license
|
zhyn456128/MultiThreadTest
|
4437b019a368ac3d3e1ebb7d4f7ac24a810abcf6
|
1183962592a6537b0756dc021b38a05c85d36678
|
refs/heads/master
| 2020-06-22T16:13:48.945382
| 2019-07-19T09:25:57
| 2019-07-19T09:25:57
| 197,743,551
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,316
|
java
|
package com.alibaba;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* 一、用于解决多线程安全问题的方式:
* 1.同步代码块 synchronized 隐式锁
* 2.同步方法 synchronized 隐式锁
* 3.同步锁Lock (jdk1.5以后) 显示锁
* 注意:显示锁,需要通过lock()方式上锁,必须通过unlock()方式进行释放锁
*/
public class Test {
public static void main(String[] args) {
Ticket ticket = new Ticket();
new Thread(ticket, "1号窗口").start();
new Thread(ticket, "2号窗口").start();
new Thread(ticket, "3号窗口").start();
}
}
class Ticket implements Runnable {
private int tick = 400;
private Lock lock = new ReentrantLock();
public void run() {
while (tick > 0) {
lock.lock();
try {
if (tick > 0) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(Thread.currentThread().getName() + " 完成售票,余票为 " + --tick);
}
} finally {
lock.unlock();
}
}
}
}
|
[
"zhaoyanan@zhaoyanandeMacBook-Pro.local"
] |
zhaoyanan@zhaoyanandeMacBook-Pro.local
|
834fb9c1e4fb390f5dc1b11def2e480e79907751
|
e6a4fc9daf1d7cdbc2b8c9cfe16031e94c3b9cc4
|
/src/main/java/com/example/demo/domain/OfficeLocation.java
|
02d79a795b3f2147e60b5eba298c7f44a4e91fa6
|
[] |
no_license
|
blueswebber/db_project
|
4201a679787e58d6dcca91b4db49b111852d6dfa
|
70dca52c3df5d1059da2e0d3646e092410f09680
|
refs/heads/master
| 2023-02-02T23:17:20.919761
| 2020-12-15T08:09:30
| 2020-12-15T08:10:27
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 808
|
java
|
package com.example.demo.domain;
import com.example.demo.domain.support.State;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
@Table(name = "OFFICE_LOCATION")
@Getter
@Setter
public class OfficeLocation extends BaseModel{
@Column(nullable = false)
private String ofc_street_add;
@Column(nullable = false)
private String ofc_city;
@Column(nullable = false)
@Enumerated(EnumType.STRING)
private State ofc_state;
@Column(nullable = false)
private Integer ofc_zipcode;
@Column(nullable = false)
private Long ofc_number;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "officeLocation", cascade = CascadeType.REMOVE)
private List<Vehicle> vehicles= new ArrayList<>();
}
|
[
"ventusxu0905@gmail.com"
] |
ventusxu0905@gmail.com
|
24e57c7886ed8bfe9a2c368cba7d067f319805f1
|
a3b5d19f1d616ed6677d4279aa344171a5f6a720
|
/src/main/java/com/bp/bll/ThreadMonitor.java
|
2cbaa9efc140821ef2a80971db01a1a7c78d6a45
|
[] |
no_license
|
hongyingJake/BPAnalisysServer
|
a907a992041d4d8f10de9b947e50e711cf64f353
|
c8d41eedaf9676cffc64a46e4828491adea36de6
|
refs/heads/master
| 2020-03-17T13:47:50.902645
| 2018-05-16T09:52:47
| 2018-05-16T10:03:28
| 133,644,915
| 1
| 0
| null | null | null | null |
GB18030
|
Java
| false
| false
| 8,079
|
java
|
package com.bp.bll;
import java.io.File;
import java.io.FileInputStream;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import com.bp.common.*;
import com.bp.msgfactory.*;
import com.bp.msginterface.*;
/**
* @author zyk
* @version 创建时间:2017年8月7日 下午4:10:46
* Web 服务线程监视工具 (监视消息队列服务器是否正常工作)类说明
*/
public class ThreadMonitor implements Runnable {
/*
* 线程运行入口
* @see java.lang.Runnable#run()
*/
public void run()
{
MonitorMQAPI();
}
/**
* 线程空闲休息时间,单位:秒
*/
private static int ThreadFreeTime=1;
static{
ConfigurationManager mgr=new ConfigurationManager();
String freeTime=mgr.ReadConfiByNodeName("ThreadFreeTime")==""?"1":mgr.ReadConfiByNodeName("ThreadFreeTime");
ThreadFreeTime=Integer.parseInt(freeTime);
}
/**
* API服务监视消息队列
*/
private void MonitorMQAPI()
{
IBaseMQ mQ=MQFactory.GetMQInfo();
while(true)
{
//判断消息队列是否可用
if (!BPFlg.getMSMQServerCanUse() && mQ.CanUseMQ())
{
//1:设置消息队列标识符可用
if (!BPFlg.getMSMQServerCanUse())
{
BPFlg.setMSMQServerCanUse(true);
LogWritter.LogWritterInfo(ThreadMonitor.class, LogEnum.Error,String.format("线程:%s API服务监视器--已查看到MQ消息服务已启动!", Thread.currentThread().getId()));
}
}
else if (BPFlg.getMSMQServerCanUse())
{
//查看是否有持久化消息需要写入到服务
//2:从持久化文本文件中读取消息写入到MQ中
try
{
//递归遍历共享文件目录,有文件则读取文件信息发送MQ
DGDirFile(SaveMQLocal.ShareDir);
//指定的时间单位为秒
ThreadSleep(ThreadFreeTime);
}
catch (Exception e)
{
e.printStackTrace();
LogWritter.LogWritterInfo(ThreadMonitor.class, LogEnum.Error,"API监视线程异常,"+e.getMessage());
}
}
else
{
//指定的时间单位为秒
ThreadSleep(ThreadFreeTime);
}
}
}
/**
* 线程休息指定的时间
* @param times 单位:秒
*/
private void ThreadSleep(int times){
//指定的时间单位为秒
try
{
Thread.sleep(times * 1000);
}
catch (InterruptedException e)
{
LogWritter.LogWritterInfo(ThreadMonitor.class, LogEnum.Error,"API监视线程Sleep指定的时间异常,"+e.toString());
}
}
/**
* 读取全部文件的内容写入到消息队列
* @param f
*/
private void ReadAllFileContent(File f)
{
String content= SaveMQLocal.GetInfoBackClear(f.getAbsolutePath());
if(content!=null&&content.length()>0)
{
//消息添加到消息队列服务器,每一个消息都有一个换行符分隔
String[] MQSum=content.split("\r\n");
StringBuilder sb=new StringBuilder();
for(String msg:MQSum)
{
if(msg.trim().length()<=0)
{
continue;
}
if(!BPFlg.getMSMQServerCanUse()){
sb.append(msg);
sb.append("\r\n");
//SaveMQLocal.SaveMQToTxt(msg);
continue;
}
try
{
//不需要转换对象,保存时就说一个JSON字符串
//Object obj= JsonUtility.JSONStrToObj(msg);
//获取到key
String strSum = msg.substring(1, msg.length() - 2);
String[] sum=strSum.split(":\\[");
if(sum!=null&&sum.length==2)
{
String key=sum[0].replaceAll("\"", "");
Object obj=msg;
if(obj!=null)
{
MQFactory.GetMQInfo().SaveMQInfo(key,obj);
//System.out.println(obj);
}
}
}
catch(Exception e)
{
BPFlg.setMSMQServerCanUse(false);
//保存到文本文件
SaveMQLocal.SaveMQToTxt(msg);
//记录日志
LogWritter.LogWritterInfo(ThreadMonitor.class, LogEnum.Error,String.format("线程:%s 读取本地持久化文件到MQ过程,MQ服务异常,消息再次持久化到本地!", Thread.currentThread().getId()));
//停止当前线程指定时间
ThreadSleep(ThreadFreeTime);
e.printStackTrace();
}
}
//未发送的数据重新持久化到本地
if(sb.length()>0){
SaveMQLocal.SaveMQToTxt(sb);
}
}
else
{
ThreadSleep(ThreadFreeTime);
}
}
/**
* 重命名文件逐行读取文件后删除文件
* @param f
*/
private void ReadRowFileContent(File f){
String Absolute=f.getAbsolutePath();//文件绝对地址
String resetName=Absolute+".current";//重命名后的文件
//文件内容过大需独立出来读取,重新命名文件
File newFile=new File(resetName);
//重命名后的文件只有当前这个进程访问,可逐行读取
FileInputStream inputStream = null;
Scanner sc = null;
try {
f.renameTo(newFile);
inputStream = new FileInputStream(newFile);
//通过Scanner可一行一行读取,不会像ReadBuffer一样都读取到内存然后在一行读取,容易内存溢出
sc = new Scanner(inputStream, "UTF-8");
while (sc.hasNextLine()) {
String line = sc.nextLine();
//获取到key
String strSum = line.substring(1, line.length() - 2);
String[] sum=strSum.split(":\\[");
if(sum!=null&&sum.length==2)
{
String key=sum[0].replaceAll("\"", "");
try{
MQFactory.GetMQInfo().SaveMQInfo(key,line);
}
catch(Exception e)
{
e.printStackTrace();
BPFlg.setMSMQServerCanUse(false);
//保存到文本文件
SaveMQLocal.SaveMQToTxt(line);
LogWritter.LogWritterInfo(ThreadMonitor.class, LogEnum.Error,"API监视线程逐行读取写入消息队列异常,已重新持久化本地,"+e.getMessage());
}
}
}
}
catch(Exception e)
{
LogWritter.LogWritterInfo(ThreadMonitor.class, LogEnum.Error,"API监视线程逐行读取消息异常"+e.getMessage());
e.printStackTrace();
}
finally {
if (inputStream != null) {
try{
inputStream.close();
}
catch(Exception e){
LogWritter.LogWritterInfo(ThreadMonitor.class, LogEnum.Error,"API监视线程关闭临时读取文件流异常"+e.getMessage());
e.printStackTrace();
}
}
if (sc != null) {
sc.close();
}
}
//读取完文件进行文件删除
try{
newFile.delete();
}
catch(Exception e){
LogWritter.LogWritterInfo(ThreadMonitor.class, LogEnum.Error,"API监视线程删除临时文件异常"+e.getMessage());
e.printStackTrace();
}
}
/**
* 从本地文件读取消息发送到消息队列服务中
* @param Dir
*/
private void DGDirFile(String Dir)
{
File file=new File(Dir);
if(file.isDirectory()&&file.exists())
{
if(BPFlg.getMSMQServerCanUse())
{
File[] files= file.listFiles();
for(File f:files)
{
if(!f.isDirectory()&&BPFlg.getMSMQServerCanUse())
{
//判断文件大小,大于500MB则逐行读取信息到消息队列(内存溢出),否则读取整个文件内容到消息队列
String fileName=f.getName();
String prefix=fileName.substring(fileName.lastIndexOf(".")+1);//文件扩展名
if(f.length()/1024/1024>500&&!prefix.equals("current")){
//重新命名文件,然后逐行读取发送
ReadRowFileContent(f);
}
else if(prefix.equals("current")){
//当前正在处理的文档,不进行操作
}
else
{
ReadAllFileContent(f);
}
}
else
{
//为目录则递归遍历
DGDirFile(f.getAbsolutePath());
}
//遍历玩一个目录或文件则停一下线程(防止系统死机)
ThreadSleep(ThreadFreeTime);
}
}
else
{
ThreadSleep(ThreadFreeTime);
}
}
else
{
ThreadSleep(ThreadFreeTime);
}
}
}
|
[
"zhang731610067@163.com"
] |
zhang731610067@163.com
|
8d76a76f98792527334aacb4050d9711a2b545db
|
06cf20254b125e5a421fafccca1b18e0b9346b98
|
/libraries/network/src/main/java/com/szy/lib/network/Retrofit/factory/CustomGsonResponseBodyConverter.java
|
e01def3b12c07c6eae442f0cc27ccf1587d2ce8a
|
[] |
no_license
|
songzhiyin/kotlinDemo
|
16121386d8f3115814af640d19cb5d07f8190472
|
4c53005df8631ac745b0d2e53fc2c9f56f37587c
|
refs/heads/master
| 2022-11-07T13:43:20.828952
| 2020-06-28T07:02:24
| 2020-06-28T07:02:24
| 267,467,470
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,572
|
java
|
package com.szy.lib.network.Retrofit.factory;
import com.google.gson.Gson;
import com.google.gson.JsonIOException;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import okhttp3.ResponseBody;
import retrofit2.Converter;
/**
* 版权:易金 版权所有
* <p>
* 作者:suntinghui
* <p>
* 创建日期:2018/11/21 0021 11:24
* <p>
* 描述:
* <p>
* 修订历史:
*/
final class CustomGsonResponseBodyConverter<T> implements Converter<ResponseBody, T> {
private final Gson gson;
private final TypeAdapter<T> adapter;
CustomGsonResponseBodyConverter(Gson gson, TypeAdapter<T> adapter) {
this.gson = gson;
this.adapter = adapter;
}
@Override
public T convert(ResponseBody value) throws IOException {
// JSONObject jsonObject = null;
// try {
// jsonObject = new JSONObject(value.string());
// } catch (Exception e) {
// e.printStackTrace();
// value.close();
// }
Reader reader = new StringReader(value.string());
JsonReader jsonReader = gson.newJsonReader(reader);
try {
T result = adapter.read(jsonReader);
if (jsonReader.peek() != JsonToken.END_DOCUMENT) {
throw new JsonIOException("JSON document was not fully consumed.");
}
return result;
} finally {
value.close();
}
}
}
|
[
"916924575@qq.com"
] |
916924575@qq.com
|
06c653c6cb82adac437e009057ba9046592c3c94
|
c06a78393b952d6ad09b9ce4b445388176422337
|
/src/com/hyr/hubei/polytechnic/university/competition/system/domain/Article.java
|
feb675512e65bd1578b165134d89c937a4f04779
|
[] |
no_license
|
huangyueranbbc/CompetitionSystem
|
aab44d8b95ba724565c6341c78e77d55decfa03c
|
be45f9ecd45c224a621bbbe2fe648b0f9b4ad4bf
|
refs/heads/master
| 2023-05-06T03:28:52.816449
| 2021-05-31T05:58:42
| 2021-05-31T05:58:42
| 72,910,311
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,095
|
java
|
package com.hyr.hubei.polytechnic.university.competition.system.domain;
import java.util.Date;
/**
* 2016-11-4 21:25:37
*
* @category 文章 回复和主题的父类
* @author 黄跃然
*/
public class Article {
/** id主键 */
private Long id;
/** 作者 */
private User author;
/** 发表时间 */
private Date postTime;
/** ip地址 */
private String ipAddr;
/** 是否删除 0未删除 1已删除 默认值0 */
private Integer isdel=0;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public User getAuthor() {
return author;
}
public void setAuthor(User author) {
this.author = author;
}
public Date getPostTime() {
return postTime;
}
public void setPostTime(Date postTime) {
this.postTime = postTime;
}
public String getIpAddr() {
return ipAddr;
}
public void setIpAddr(String ipAddr) {
this.ipAddr = ipAddr;
}
public Integer getIsdel() {
return isdel;
}
public void setIsdel(Integer isdel) {
this.isdel = isdel;
}
}
|
[
"huangyueran@DESKTOP-U61RP8O"
] |
huangyueran@DESKTOP-U61RP8O
|
7415e223a70228e4a61ff9ff2f37311c6d500462
|
fa91450deb625cda070e82d5c31770be5ca1dec6
|
/Diff-Raw-Data/5/5_ad16fc34f2f70a71f8dd0f626465d1c3ec0736b9/ExpressionTransformer/5_ad16fc34f2f70a71f8dd0f626465d1c3ec0736b9_ExpressionTransformer_s.java
|
f91ab704b42f65d6d1e3f03f24662215c8187179
|
[] |
no_license
|
zhongxingyu/Seer
|
48e7e5197624d7afa94d23f849f8ea2075bcaec0
|
c11a3109fdfca9be337e509ecb2c085b60076213
|
refs/heads/master
| 2023-07-06T12:48:55.516692
| 2023-06-22T07:55:56
| 2023-06-22T07:55:56
| 259,613,157
| 6
| 2
| null | 2023-06-22T07:55:57
| 2020-04-28T11:07:49
| null |
UTF-8
|
Java
| false
| false
| 85,789
|
java
|
/*
* Copyright Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the authors tag. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License version 2.
*
* This particular file is subject to the "Classpath" exception as provided in the
* LICENSE file that accompanied this code.
*
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License,
* along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
package com.redhat.ceylon.compiler.java.codegen;
import java.util.Arrays;
import java.util.LinkedList;
import com.redhat.ceylon.compiler.java.codegen.Operators.AssignmentOperatorTranslation;
import com.redhat.ceylon.compiler.java.codegen.Operators.OperatorTranslation;
import com.redhat.ceylon.compiler.java.codegen.Operators.OptimisationStrategy;
import com.redhat.ceylon.compiler.java.util.Decl;
import com.redhat.ceylon.compiler.java.util.Util;
import com.redhat.ceylon.compiler.typechecker.model.ClassOrInterface;
import com.redhat.ceylon.compiler.typechecker.model.Declaration;
import com.redhat.ceylon.compiler.typechecker.model.Functional;
import com.redhat.ceylon.compiler.typechecker.model.Getter;
import com.redhat.ceylon.compiler.typechecker.model.Interface;
import com.redhat.ceylon.compiler.typechecker.model.Method;
import com.redhat.ceylon.compiler.typechecker.model.Parameter;
import com.redhat.ceylon.compiler.typechecker.model.ParameterList;
import com.redhat.ceylon.compiler.typechecker.model.ProducedType;
import com.redhat.ceylon.compiler.typechecker.model.Scope;
import com.redhat.ceylon.compiler.typechecker.model.TypeParameter;
import com.redhat.ceylon.compiler.typechecker.model.TypedDeclaration;
import com.redhat.ceylon.compiler.typechecker.model.Value;
import com.redhat.ceylon.compiler.typechecker.tree.Node;
import com.redhat.ceylon.compiler.typechecker.tree.Tree;
import com.redhat.ceylon.compiler.typechecker.tree.Tree.SpecifierExpression;
import com.sun.tools.javac.code.TypeTags;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCConditional;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCExpressionStatement;
import com.sun.tools.javac.tree.JCTree.JCForLoop;
import com.sun.tools.javac.tree.JCTree.JCLiteral;
import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
import com.sun.tools.javac.tree.JCTree.JCNewArray;
import com.sun.tools.javac.tree.JCTree.JCNewClass;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCUnary;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
/**
* This transformer deals with expressions only
*/
public class ExpressionTransformer extends AbstractTransformer {
static{
// only there to make sure this class is initialised before the enums defined in it, otherwise we
// get an initialisation error
Operators.init();
}
private boolean inStatement = false;
private boolean needDollarThis = false;
public static ExpressionTransformer getInstance(Context context) {
ExpressionTransformer trans = context.get(ExpressionTransformer.class);
if (trans == null) {
trans = new ExpressionTransformer(context);
context.put(ExpressionTransformer.class, trans);
}
return trans;
}
private ExpressionTransformer(Context context) {
super(context);
}
//
// Statement expressions
public JCStatement transform(Tree.ExpressionStatement tree) {
// ExpressionStatements do not return any value, therefore we don't care about the type of the expressions.
inStatement = true;
JCStatement result = at(tree).Exec(transformExpression(tree.getExpression(), BoxingStrategy.INDIFFERENT, null));
inStatement = false;
return result;
}
public JCStatement transform(Tree.SpecifierStatement op) {
// SpecifierStatement do not return any value, therefore we don't care about the type of the expressions.
inStatement = true;
JCStatement result = at(op).Exec(transformAssignment(op, op.getBaseMemberExpression(), op.getSpecifierExpression().getExpression()));
inStatement = false;
return result;
}
//
// Any sort of expression
JCExpression transformExpression(final Tree.Term expr) {
return transformExpression(expr, BoxingStrategy.BOXED, null);
}
JCExpression transformExpression(final Tree.Term expr, BoxingStrategy boxingStrategy, ProducedType expectedType) {
if (expr == null) {
return null;
}
at(expr);
if (inStatement && boxingStrategy != BoxingStrategy.INDIFFERENT) {
// We're not directly inside the ExpressionStatement anymore
inStatement = false;
}
CeylonVisitor v = new CeylonVisitor(gen());
// FIXME: shouldn't that be in the visitor?
if (expr instanceof Tree.Expression) {
// Cope with things like ((expr))
Tree.Expression expr2 = (Tree.Expression)expr;
while(((Tree.Expression)expr2).getTerm() instanceof Tree.Expression) {
expr2 = (Tree.Expression)expr2.getTerm();
}
expr2.visitChildren(v);
} else {
expr.visit(v);
}
if (!v.hasResult()) {
return make().Erroneous();
}
JCExpression result = v.getSingleResult();
result = applyErasureAndBoxing(result, expr, boxingStrategy, expectedType);
return result;
}
//
// Boxing and erasure of expressions
private JCExpression applyErasureAndBoxing(JCExpression result, Tree.Term expr, BoxingStrategy boxingStrategy, ProducedType expectedType) {
ProducedType exprType = expr.getTypeModel();
boolean exprBoxed = !Util.isUnBoxed(expr);
return applyErasureAndBoxing(result, exprType, exprBoxed, boxingStrategy, expectedType);
}
private JCExpression applyErasureAndBoxing(JCExpression result, ProducedType exprType,
boolean exprBoxed,
BoxingStrategy boxingStrategy, ProducedType expectedType) {
if (expectedType != null
&& !(expectedType.getDeclaration() instanceof TypeParameter)
&& willEraseToObject(exprType)
// don't add cast to an erased type
&& !willEraseToObject(expectedType)
// don't add cast for null
&& !isNothing(exprType)) {
// Erased types need a type cast
JCExpression targetType = makeJavaType(expectedType, AbstractTransformer.TYPE_ARGUMENT);
exprType = expectedType;
result = make().TypeCast(targetType, result);
}
// we must to the boxing after the cast to the proper type
return boxUnboxIfNecessary(result, exprBoxed, exprType, boxingStrategy);
}
//
// Literals
JCExpression ceylonLiteral(String s) {
JCLiteral lit = make().Literal(s);
return lit;
}
public JCExpression transform(Tree.StringLiteral string) {
// FIXME: this is appalling
String value = string
.getText()
.substring(1, string.getText().length() - 1)
.replace("\r\n", "\n")
.replace("\r", "\n")
.replace("\\b", "\b")
.replace("\\t", "\t")
.replace("\\n", "\n")
.replace("\\f", "\f")
.replace("\\r", "\r")
.replace("\\\\", "\\")
.replace("\\\"", "\"")
.replace("\\'", "'")
.replace("\\`", "`");
at(string);
return ceylonLiteral(value);
}
public JCExpression transform(Tree.QuotedLiteral string) {
String value = string
.getText()
.substring(1, string.getText().length() - 1);
JCExpression result = makeSelect(makeIdent(syms().ceylonQuotedType), "instance");
return at(string).Apply(null, result, List.<JCTree.JCExpression>of(make().Literal(value)));
}
public JCExpression transform(Tree.CharLiteral lit) {
// FIXME: go unicode, but how?
JCExpression expr = make().Literal(TypeTags.CHAR, (int) lit.getText().charAt(1));
// XXX make().Literal(lit.value) doesn't work here... something
// broken in javac?
return expr;
}
public JCExpression transform(Tree.FloatLiteral lit) {
JCExpression expr = make().Literal(Double.parseDouble(lit.getText()));
return expr;
}
public JCExpression transform(Tree.NaturalLiteral lit) {
JCExpression expr = make().Literal(Long.parseLong(lit.getText()));
return expr;
}
public JCExpression transformStringExpression(Tree.StringTemplate expr) {
at(expr);
JCExpression builder;
builder = make().NewClass(null, null, makeQualIdentFromString("java.lang.StringBuilder"), List.<JCExpression>nil(), null);
java.util.List<Tree.StringLiteral> literals = expr.getStringLiterals();
java.util.List<Tree.Expression> expressions = expr.getExpressions();
for (int ii = 0; ii < literals.size(); ii += 1) {
Tree.StringLiteral literal = literals.get(ii);
if (!"\"\"".equals(literal.getText())) {// ignore empty string literals
at(literal);
builder = make().Apply(null, makeSelect(builder, "append"), List.<JCExpression>of(transform(literal)));
}
if (ii == expressions.size()) {
// The loop condition includes the last literal, so break out
// after that because we've already exhausted all the expressions
break;
}
Tree.Expression expression = expressions.get(ii);
at(expression);
// Here in both cases we don't need a type cast for erasure
if (isCeylonBasicType(expression.getTypeModel())) {// TODO: Test should be erases to String, long, int, boolean, char, byte, float, double
// If erases to a Java primitive just call append, don't box it just to call format.
builder = make().Apply(null, makeSelect(builder, "append"), List.<JCExpression>of(transformExpression(expression, BoxingStrategy.UNBOXED, null)));
} else {
JCMethodInvocation formatted = make().Apply(null, makeSelect(transformExpression(expression), "toString"), List.<JCExpression>nil());
builder = make().Apply(null, makeSelect(builder, "append"), List.<JCExpression>of(formatted));
}
}
return make().Apply(null, makeSelect(builder, "toString"), List.<JCExpression>nil());
}
public JCExpression transform(Tree.SequenceEnumeration value) {
at(value);
if (value.getExpressionList() == null) {
return makeEmpty();
} else {
java.util.List<Tree.Expression> list = value.getExpressionList().getExpressions();
ProducedType seqElemType = value.getTypeModel().getTypeArgumentList().get(0);
return makeSequence(list, seqElemType);
}
}
public JCTree transform(Tree.This expr) {
at(expr);
if (needDollarThis) {
return makeUnquotedIdent("$this");
} else {
return makeUnquotedIdent("this");
}
}
public JCTree transform(Tree.Super expr) {
at(expr);
return makeUnquotedIdent("super");
}
public JCTree transform(Tree.Outer expr) {
at(expr);
ProducedType outerClass = com.redhat.ceylon.compiler.typechecker.model.Util.getOuterClassOrInterface(expr.getScope());
return makeSelect(outerClass.getDeclaration().getName(), "this");
}
//
// Unary and Binary operators that can be overridden
//
// Unary operators
public JCExpression transform(Tree.NotOp op) {
// No need for an erasure cast since Term must be Boolean and we never need to erase that
JCExpression term = transformExpression(op.getTerm(), Util.getBoxingStrategy(op), null);
JCUnary jcu = at(op).Unary(JCTree.NOT, term);
return jcu;
}
public JCExpression transform(Tree.IsOp op) {
// we don't need any erasure type cast for an "is" test
JCExpression expression = transformExpression(op.getTerm());
at(op);
return makeTypeTest(expression, op.getType().getTypeModel());
}
public JCTree transform(Tree.Nonempty op) {
// we don't need any erasure type cast for a "nonempty" test
JCExpression expression = transformExpression(op.getTerm());
at(op);
return makeTypeTest(expression, op.getUnit().getSequenceDeclaration().getType());
}
public JCTree transform(Tree.Exists op) {
// we don't need any erasure type cast for an "exists" test
JCExpression expression = transformExpression(op.getTerm());
at(op);
return make().Binary(JCTree.NE, expression, makeNull());
}
public JCExpression transform(Tree.PositiveOp op) {
return transformOverridableUnaryOperator(op, op.getUnit().getInvertableDeclaration());
}
public JCExpression transform(Tree.NegativeOp op) {
return transformOverridableUnaryOperator(op, op.getUnit().getInvertableDeclaration());
}
public JCExpression transform(Tree.UnaryOperatorExpression op) {
return transformOverridableUnaryOperator(op, (ProducedType)null);
}
private JCExpression transformOverridableUnaryOperator(Tree.UnaryOperatorExpression op, Interface compoundType) {
ProducedType leftType = getSupertype(op.getTerm(), compoundType);
return transformOverridableUnaryOperator(op, leftType);
}
private JCExpression transformOverridableUnaryOperator(Tree.UnaryOperatorExpression op, ProducedType expectedType) {
at(op);
Tree.Term term = op.getTerm();
OperatorTranslation operator = Operators.getOperator(op.getClass());
if (operator == null) {
return make().Erroneous();
}
if(operator.getOptimisationStrategy(op, this).useJavaOperator()){
// optimisation for unboxed types
JCExpression expr = transformExpression(term, BoxingStrategy.UNBOXED, expectedType);
// unary + is essentially a NOOP
if(operator == OperatorTranslation.UNARY_POSITIVE)
return expr;
return make().Unary(operator.javacOperator, expr);
}
return make().Apply(null, makeSelect(transformExpression(term, BoxingStrategy.BOXED, expectedType),
Util.getGetterName(operator.ceylonMethod)), List.<JCExpression> nil());
}
//
// Binary operators
public JCExpression transform(Tree.NotEqualOp op) {
OperatorTranslation operator = Operators.OperatorTranslation.BINARY_EQUAL;
OptimisationStrategy optimisationStrategy = operator.getOptimisationStrategy(op, this);
// we want it unboxed only if the operator is optimised
// we don't care about the left erased type, since equals() is on Object
JCExpression left = transformExpression(op.getLeftTerm(), optimisationStrategy.getBoxingStrategy(), null);
// we don't care about the right erased type, since equals() is on Object
JCExpression expr = transformOverridableBinaryOperator(op, operator, optimisationStrategy, left, null);
return at(op).Unary(JCTree.NOT, expr);
}
public JCExpression transform(Tree.RangeOp op) {
// we need to get the range bound type
ProducedType comparableType = getSupertype(op.getLeftTerm(), op.getUnit().getComparableDeclaration());
ProducedType paramType = getTypeArgument(comparableType);
JCExpression lower = transformExpression(op.getLeftTerm(), BoxingStrategy.BOXED, paramType);
JCExpression upper = transformExpression(op.getRightTerm(), BoxingStrategy.BOXED, paramType);
ProducedType rangeType = typeFact().getRangeType(op.getLeftTerm().getTypeModel());
JCExpression typeExpr = makeJavaType(rangeType, CeylonTransformer.CLASS_NEW);
return at(op).NewClass(null, null, typeExpr, List.<JCExpression> of(lower, upper), null);
}
public JCExpression transform(Tree.EntryOp op) {
// no erasure cast needed for both terms
JCExpression key = transformExpression(op.getLeftTerm());
JCExpression elem = transformExpression(op.getRightTerm());
ProducedType entryType = typeFact().getEntryType(op.getLeftTerm().getTypeModel(), op.getRightTerm().getTypeModel());
JCExpression typeExpr = makeJavaType(entryType, CeylonTransformer.CLASS_NEW);
return at(op).NewClass(null, null, typeExpr , List.<JCExpression> of(key, elem), null);
}
public JCTree transform(Tree.DefaultOp op) {
JCExpression left = transformExpression(op.getLeftTerm());
JCExpression right = transformExpression(op.getRightTerm());
String varName = tempName();
JCExpression varIdent = makeUnquotedIdent(varName);
JCExpression test = at(op).Binary(JCTree.NE, varIdent, makeNull());
JCExpression cond = make().Conditional(test , varIdent, right);
JCExpression typeExpr = makeJavaType(op.getTypeModel(), NO_PRIMITIVES);
return makeLetExpr(varName, null, typeExpr, left, cond);
}
public JCTree transform(Tree.ThenOp op) {
JCExpression left = transformExpression(op.getLeftTerm(), Util.getBoxingStrategy(op.getLeftTerm()), typeFact().getBooleanDeclaration().getType());
JCExpression right = transformExpression(op.getRightTerm());
return make().Conditional(left , right, makeNull());
}
public JCTree transform(Tree.InOp op) {
JCExpression left = transformExpression(op.getLeftTerm(), BoxingStrategy.BOXED, typeFact().getEqualityDeclaration().getType());
JCExpression right = transformExpression(op.getRightTerm(), BoxingStrategy.BOXED, typeFact().getCategoryDeclaration().getType());
String varName = tempName();
JCExpression varIdent = makeUnquotedIdent(varName);
JCExpression contains = at(op).Apply(null, makeSelect(right, "contains"), List.<JCExpression> of(varIdent));
JCExpression typeExpr = makeJavaType(op.getLeftTerm().getTypeModel(), NO_PRIMITIVES);
return makeLetExpr(varName, null, typeExpr, left, contains);
}
// Logical operators
public JCExpression transform(Tree.LogicalOp op) {
OperatorTranslation operator = Operators.getOperator(op.getClass());
if(operator == null){
log.error("ceylon", "Not supported yet: "+op.getNodeType());
return at(op).Erroneous(List.<JCTree>nil());
}
// Both terms are Booleans and can't be erased to anything
JCExpression left = transformExpression(op.getLeftTerm(), BoxingStrategy.UNBOXED, null);
return transformLogicalOp(op, operator, left, op.getRightTerm());
}
private JCExpression transformLogicalOp(Node op, OperatorTranslation operator,
JCExpression left, Tree.Term rightTerm) {
// Both terms are Booleans and can't be erased to anything
JCExpression right = transformExpression(rightTerm, BoxingStrategy.UNBOXED, null);
return at(op).Binary(operator.javacOperator, left, right);
}
// Comparison operators
public JCExpression transform(Tree.IdenticalOp op){
// The only thing which might be unboxed is boolean, and we can follow the rules of == for optimising it,
// which are simple and require that both types be booleans to be unboxed, otherwise they must be boxed
OptimisationStrategy optimisationStrategy = OperatorTranslation.BINARY_EQUAL.getOptimisationStrategy(op, this);
JCExpression left = transformExpression(op.getLeftTerm(), optimisationStrategy.getBoxingStrategy(), null);
JCExpression right = transformExpression(op.getRightTerm(), optimisationStrategy.getBoxingStrategy(), null);
return at(op).Binary(JCTree.EQ, left, right);
}
public JCExpression transform(Tree.ComparisonOp op) {
return transformOverridableBinaryOperator(op, op.getUnit().getComparableDeclaration());
}
public JCExpression transform(Tree.CompareOp op) {
return transformOverridableBinaryOperator(op, op.getUnit().getComparableDeclaration());
}
// Arithmetic operators
public JCExpression transform(Tree.ArithmeticOp op) {
return transformOverridableBinaryOperator(op, op.getUnit().getNumericDeclaration());
}
public JCExpression transform(Tree.SumOp op) {
return transformOverridableBinaryOperator(op, op.getUnit().getSummableDeclaration());
}
public JCExpression transform(Tree.RemainderOp op) {
return transformOverridableBinaryOperator(op, op.getUnit().getIntegralDeclaration());
}
// Overridable binary operators
public JCExpression transform(Tree.BinaryOperatorExpression op) {
return transformOverridableBinaryOperator(op, null, null);
}
private JCExpression transformOverridableBinaryOperator(Tree.BinaryOperatorExpression op, Interface compoundType) {
ProducedType leftType = getSupertype(op.getLeftTerm(), compoundType);
ProducedType rightType = getTypeArgument(leftType);
return transformOverridableBinaryOperator(op, leftType, rightType);
}
private JCExpression transformOverridableBinaryOperator(Tree.BinaryOperatorExpression op, ProducedType leftType, ProducedType rightType) {
OperatorTranslation operator = Operators.getOperator(op.getClass());
if (operator == null) {
return make().Erroneous();
}
OptimisationStrategy optimisationStrategy = operator.getOptimisationStrategy(op, this);
JCExpression left = transformExpression(op.getLeftTerm(), optimisationStrategy.getBoxingStrategy(), leftType);
return transformOverridableBinaryOperator(op, operator, optimisationStrategy, left, rightType);
}
private JCExpression transformOverridableBinaryOperator(Tree.BinaryOperatorExpression op,
OperatorTranslation originalOperator, OptimisationStrategy optimisatonStrategy,
JCExpression left, ProducedType rightType) {
JCExpression result = null;
JCExpression right = transformExpression(op.getRightTerm(), optimisatonStrategy.getBoxingStrategy(), rightType);
// optimise if we can
if(optimisatonStrategy.useJavaOperator()){
return make().Binary(originalOperator.javacOperator, left, right);
}
boolean loseComparison =
originalOperator == OperatorTranslation.BINARY_SMALLER
|| originalOperator == OperatorTranslation.BINARY_SMALL_AS
|| originalOperator == OperatorTranslation.BINARY_LARGER
|| originalOperator == OperatorTranslation.BINARY_LARGE_AS;
// for comparisons we need to invoke compare()
OperatorTranslation actualOperator = originalOperator;
if (loseComparison) {
actualOperator = Operators.OperatorTranslation.BINARY_COMPARE;
if (actualOperator == null) {
return make().Erroneous();
}
}
result = at(op).Apply(null, makeSelect(left, actualOperator.ceylonMethod), List.of(right));
if (loseComparison) {
result = at(op).Apply(null, makeSelect(result, originalOperator.ceylonMethod), List.<JCExpression> nil());
}
return result;
}
//
// Operator-Assignment expressions
public JCExpression transform(final Tree.ArithmeticAssignmentOp op){
final AssignmentOperatorTranslation operator = Operators.getAssignmentOperator(op.getClass());
if(operator == null){
log.error("ceylon", "Not supported yet: "+op.getNodeType());
return at(op).Erroneous(List.<JCTree>nil());
}
// see if we can optimise it
if(op.getUnboxed() && Util.isDirectAccessVariable(op.getLeftTerm())){
return optimiseAssignmentOperator(op, operator);
}
// we can use unboxed types if both operands are unboxed
final boolean boxResult = !op.getUnboxed();
// find the proper type
Interface compoundType = op.getUnit().getNumericDeclaration();
if(op instanceof Tree.AddAssignOp){
compoundType = op.getUnit().getSummableDeclaration();
}else if(op instanceof Tree.RemainderAssignOp){
compoundType = op.getUnit().getIntegralDeclaration();
}
final ProducedType leftType = getSupertype(op.getLeftTerm(), compoundType);
final ProducedType rightType = getTypeArgument(leftType, 0);
// we work on boxed types
return transformAssignAndReturnOperation(op, op.getLeftTerm(), boxResult,
leftType, rightType,
new AssignAndReturnOperationFactory(){
@Override
public JCExpression getNewValue(JCExpression previousValue) {
// make this call: previousValue OP RHS
return transformOverridableBinaryOperator(op, operator.binaryOperator,
boxResult ? OptimisationStrategy.NONE : OptimisationStrategy.OPTIMISE,
previousValue, rightType);
}
});
}
public JCExpression transform(Tree.BitwiseAssignmentOp op){
log.error("ceylon", "Not supported yet: "+op.getNodeType());
return at(op).Erroneous(List.<JCTree>nil());
}
public JCExpression transform(final Tree.LogicalAssignmentOp op){
final AssignmentOperatorTranslation operator = Operators.getAssignmentOperator(op.getClass());
if(operator == null){
log.error("ceylon", "Not supported yet: "+op.getNodeType());
return at(op).Erroneous(List.<JCTree>nil());
}
// optimise if we can
if(Util.isDirectAccessVariable(op.getLeftTerm())){
return optimiseAssignmentOperator(op, operator);
}
ProducedType valueType = op.getLeftTerm().getTypeModel();
// we work on unboxed types
return transformAssignAndReturnOperation(op, op.getLeftTerm(), false,
valueType, valueType, new AssignAndReturnOperationFactory(){
@Override
public JCExpression getNewValue(JCExpression previousValue) {
// make this call: previousValue OP RHS
return transformLogicalOp(op, operator.binaryOperator,
previousValue, op.getRightTerm());
}
});
}
private JCExpression optimiseAssignmentOperator(final Tree.AssignmentOp op, final AssignmentOperatorTranslation operator) {
// we don't care about their types since they're unboxed and we know it
JCExpression left = transformExpression(op.getLeftTerm(), BoxingStrategy.UNBOXED, null);
JCExpression right = transformExpression(op.getRightTerm(), BoxingStrategy.UNBOXED, null);
return at(op).Assignop(operator.javacOperator, left, right);
}
// Postfix operator
public JCExpression transform(Tree.PostfixOperatorExpression expr) {
OperatorTranslation operator = Operators.getOperator(expr.getClass());
if(operator == null){
log.error("ceylon", "Not supported yet: "+expr.getNodeType());
return at(expr).Erroneous(List.<JCTree>nil());
}
OptimisationStrategy optimisationStrategy = operator.getOptimisationStrategy(expr, this);
boolean canOptimise = optimisationStrategy.useJavaOperator();
// only fully optimise if we don't have to access the getter/setter
if(canOptimise && Util.isDirectAccessVariable(expr.getTerm())){
JCExpression term = transformExpression(expr.getTerm(), BoxingStrategy.UNBOXED, expr.getTypeModel());
return at(expr).Unary(operator.javacOperator, term);
}
Interface compoundType = expr.getUnit().getOrdinalDeclaration();
ProducedType valueType = getSupertype(expr.getTerm(), compoundType);
ProducedType returnType = getTypeArgument(valueType, 0);
Tree.Term term = expr.getTerm();
List<JCVariableDecl> decls = List.nil();
List<JCStatement> stats = List.nil();
JCExpression result = null;
// attr++
// (let $tmp = attr; attr = $tmp.getSuccessor(); $tmp;)
if(term instanceof Tree.BaseMemberExpression){
// we can optimise that case a bit sometimes
boolean boxResult = !canOptimise;
JCExpression getter = transform((Tree.BaseMemberExpression)term, null);
at(expr);
// Type $tmp = attr
JCExpression exprType = makeJavaType(returnType, boxResult ? NO_PRIMITIVES : 0);
Name varName = names().fromString(tempName("op"));
// make sure we box the results if necessary
getter = applyErasureAndBoxing(getter, term, boxResult ? BoxingStrategy.BOXED : BoxingStrategy.UNBOXED, returnType);
JCVariableDecl tmpVar = make().VarDef(make().Modifiers(0), varName, exprType, getter);
decls = decls.prepend(tmpVar);
// attr = $tmp.getSuccessor()
JCExpression successor;
if(canOptimise){
// use +1/-1 if we can optimise a bit
successor = make().Binary(operator == OperatorTranslation.UNARY_POSTFIX_INCREMENT ? JCTree.PLUS : JCTree.MINUS,
make().Ident(varName), makeInteger(1));
}else{
successor = make().Apply(null,
makeSelect(make().Ident(varName), operator.ceylonMethod),
List.<JCExpression>nil());
// make sure the result is boxed if necessary, the result of successor/predecessor is always boxed
successor = boxUnboxIfNecessary(successor, true, term.getTypeModel(), Util.getBoxingStrategy(term));
}
JCExpression assignment = transformAssignment(expr, term, successor);
stats = stats.prepend(at(expr).Exec(assignment));
// $tmp
// always return boxed
result = make().Ident(varName);
}
else if(term instanceof Tree.QualifiedMemberExpression){
// e.attr++
// (let $tmpE = e, $tmpV = $tmpE.attr; $tmpE.attr = $tmpV.getSuccessor(); $tmpV;)
Tree.QualifiedMemberExpression qualified = (Tree.QualifiedMemberExpression) term;
// transform the primary, this will get us a boxed primary
JCExpression e = transformQualifiedMemberPrimary(qualified);
at(expr);
// Type $tmpE = e
JCExpression exprType = makeJavaType(qualified.getTarget().getQualifyingType(), NO_PRIMITIVES);
Name varEName = names().fromString(tempName("opE"));
JCVariableDecl tmpEVar = make().VarDef(make().Modifiers(0), varEName, exprType, e);
// Type $tmpV = $tmpE.attr
JCExpression attrType = makeJavaType(returnType, NO_PRIMITIVES);
Name varVName = names().fromString(tempName("opV"));
JCExpression getter = transformMemberExpression(qualified, make().Ident(varEName), null);
// make sure we box the results if necessary
getter = applyErasureAndBoxing(getter, term, BoxingStrategy.BOXED, returnType);
JCVariableDecl tmpVVar = make().VarDef(make().Modifiers(0), varVName, attrType, getter);
// define all the variables
decls = decls.prepend(tmpVVar);
decls = decls.prepend(tmpEVar);
// $tmpE.attr = $tmpV.getSuccessor()
JCExpression successor = make().Apply(null,
makeSelect(make().Ident(varVName), operator.ceylonMethod),
List.<JCExpression>nil());
// make sure the result is boxed if necessary, the result of successor/predecessor is always boxed
successor = boxUnboxIfNecessary(successor, true, term.getTypeModel(), Util.getBoxingStrategy(term));
JCExpression assignment = transformAssignment(expr, term, make().Ident(varEName), successor);
stats = stats.prepend(at(expr).Exec(assignment));
// $tmpV
// always return boxed
result = make().Ident(varVName);
}else{
log.error("ceylon", "Not supported yet");
return at(expr).Erroneous(List.<JCTree>nil());
}
// e?.attr++ is probably not legal
// a[i]++ is not for M1 but will be:
// (let $tmpA = a, $tmpI = i, $tmpV = $tmpA.item($tmpI); $tmpA.setItem($tmpI, $tmpV.getSuccessor()); $tmpV;)
// a?[i]++ is probably not legal
// a[i1..i1]++ and a[i1...]++ are probably not legal
// a[].attr++ and a[].e.attr++ are probably not legal
return make().LetExpr(decls, stats, result);
}
// Prefix operator
public JCExpression transform(Tree.PrefixOperatorExpression expr) {
final OperatorTranslation operator = Operators.getOperator(expr.getClass());
if(operator == null){
log.error("ceylon", "Not supported yet: "+expr.getNodeType());
return at(expr).Erroneous(List.<JCTree>nil());
}
OptimisationStrategy optimisationStrategy = operator.getOptimisationStrategy(expr, this);
final boolean canOptimise = optimisationStrategy.useJavaOperator();
// only fully optimise if we don't have to access the getter/setter
if(canOptimise && Util.isDirectAccessVariable(expr.getTerm())){
JCExpression term = transformExpression(expr.getTerm(), BoxingStrategy.UNBOXED, expr.getTypeModel());
return at(expr).Unary(operator.javacOperator, term);
}
Interface compoundType = expr.getUnit().getOrdinalDeclaration();
ProducedType valueType = getSupertype(expr.getTerm(), compoundType);
ProducedType returnType = getTypeArgument(valueType, 0);
// we work on boxed types unless we could have optimised
return transformAssignAndReturnOperation(expr, expr.getTerm(), !canOptimise,
valueType, returnType, new AssignAndReturnOperationFactory(){
@Override
public JCExpression getNewValue(JCExpression previousValue) {
// use +1/-1 if we can optimise a bit
if(canOptimise){
return make().Binary(operator == OperatorTranslation.UNARY_PREFIX_INCREMENT ? JCTree.PLUS : JCTree.MINUS,
previousValue, makeInteger(1));
}
// make this call: previousValue.getSuccessor() or previousValue.getPredecessor()
return make().Apply(null, makeSelect(previousValue, operator.ceylonMethod), List.<JCExpression>nil());
}
});
}
//
// Function to deal with expressions that have side-effects
private interface AssignAndReturnOperationFactory {
JCExpression getNewValue(JCExpression previousValue);
}
private JCExpression transformAssignAndReturnOperation(Node operator, Tree.Term term,
boolean boxResult, ProducedType valueType, ProducedType returnType,
AssignAndReturnOperationFactory factory){
List<JCVariableDecl> decls = List.nil();
List<JCStatement> stats = List.nil();
JCExpression result = null;
// attr
// (let $tmp = OP(attr); attr = $tmp; $tmp)
if(term instanceof Tree.BaseMemberExpression){
JCExpression getter = transform((Tree.BaseMemberExpression)term, null);
at(operator);
// Type $tmp = OP(attr);
JCExpression exprType = makeJavaType(returnType, boxResult ? NO_PRIMITIVES : 0);
Name varName = names().fromString(tempName("op"));
// make sure we box the results if necessary
getter = applyErasureAndBoxing(getter, term, boxResult ? BoxingStrategy.BOXED : BoxingStrategy.UNBOXED, valueType);
JCExpression newValue = factory.getNewValue(getter);
// no need to box/unbox here since newValue and $tmpV share the same boxing type
JCVariableDecl tmpVar = make().VarDef(make().Modifiers(0), varName, exprType, newValue);
decls = decls.prepend(tmpVar);
// attr = $tmp
// make sure the result is unboxed if necessary, $tmp may be boxed
JCExpression value = make().Ident(varName);
value = boxUnboxIfNecessary(value, boxResult, term.getTypeModel(), Util.getBoxingStrategy(term));
JCExpression assignment = transformAssignment(operator, term, value);
stats = stats.prepend(at(operator).Exec(assignment));
// $tmp
// return, with the box type we asked for
result = make().Ident(varName);
}
else if(term instanceof Tree.QualifiedMemberExpression){
// e.attr
// (let $tmpE = e, $tmpV = OP($tmpE.attr); $tmpE.attr = $tmpV; $tmpV;)
Tree.QualifiedMemberExpression qualified = (Tree.QualifiedMemberExpression) term;
// transform the primary, this will get us a boxed primary
JCExpression e = transformQualifiedMemberPrimary(qualified);
at(operator);
// Type $tmpE = e
JCExpression exprType = makeJavaType(qualified.getTarget().getQualifyingType(), NO_PRIMITIVES);
Name varEName = names().fromString(tempName("opE"));
JCVariableDecl tmpEVar = make().VarDef(make().Modifiers(0), varEName, exprType, e);
// Type $tmpV = OP($tmpE.attr)
JCExpression attrType = makeJavaType(returnType, boxResult ? NO_PRIMITIVES : 0);
Name varVName = names().fromString(tempName("opV"));
JCExpression getter = transformMemberExpression(qualified, make().Ident(varEName), null);
// make sure we box the results if necessary
getter = applyErasureAndBoxing(getter, term, boxResult ? BoxingStrategy.BOXED : BoxingStrategy.UNBOXED, valueType);
JCExpression newValue = factory.getNewValue(getter);
// no need to box/unbox here since newValue and $tmpV share the same boxing type
JCVariableDecl tmpVVar = make().VarDef(make().Modifiers(0), varVName, attrType, newValue);
// define all the variables
decls = decls.prepend(tmpVVar);
decls = decls.prepend(tmpEVar);
// $tmpE.attr = $tmpV
// make sure $tmpV is unboxed if necessary
JCExpression value = make().Ident(varVName);
value = boxUnboxIfNecessary(value, boxResult, term.getTypeModel(), Util.getBoxingStrategy(term));
JCExpression assignment = transformAssignment(operator, term, make().Ident(varEName), value);
stats = stats.prepend(at(operator).Exec(assignment));
// $tmpV
// return, with the box type we asked for
result = make().Ident(varVName);
}else{
log.error("ceylon", "Not supported yet");
return at(operator).Erroneous(List.<JCTree>nil());
}
// OP(e?.attr) is probably not legal
// OP(a[i]) is not for M1 but will be:
// (let $tmpA = a, $tmpI = i, $tmpV = OP($tmpA.item($tmpI)); $tmpA.setItem($tmpI, $tmpV); $tmpV;)
// OP(a?[i]) is probably not legal
// OP(a[i1..i1]) and OP(a[i1...]) are probably not legal
// OP(a[].attr) and OP(a[].e.attr) are probably not legal
return make().LetExpr(decls, stats, result);
}
public JCExpression transform(Tree.Parameter param) {
// Transform the expression marking that we're inside a defaulted parameter for $this-handling
needDollarThis = true;
SpecifierExpression spec = param.getDefaultArgument().getSpecifierExpression();
JCExpression expr = expressionGen().transformExpression(spec.getExpression(), Util.getBoxingStrategy(param.getDeclarationModel()), param.getDeclarationModel().getType());
needDollarThis = false;
return expr;
}
//
// Invocations
public JCExpression transform(Tree.InvocationExpression ce) {
if (ce.getPositionalArgumentList() != null) {
return transformPositionalInvocation(ce);
} else if (ce.getNamedArgumentList() != null) {
return transformNamedInvocation(ce);
} else {
throw new RuntimeException("Illegal State");
}
}
// Named invocation
private JCExpression transformNamedInvocation(final Tree.InvocationExpression ce) {
ListBuffer<JCVariableDecl> vars = ListBuffer.lb();
ListBuffer<JCExpression> args = ListBuffer.lb();
java.util.List<ProducedType> typeArgumentModels = getTypeArguments(ce);
List<JCExpression> typeArgs = transformTypeArguments(typeArgumentModels);
boolean isRaw = typeArgs.isEmpty();
String callVarName = null;
Declaration primaryDecl = ce.getPrimary().getDeclaration();
if (primaryDecl != null) {
java.util.List<ParameterList> paramLists = ((Functional)primaryDecl).getParameterLists();
java.util.List<Tree.NamedArgument> namedArguments = ce.getNamedArgumentList().getNamedArguments();
java.util.List<Parameter> declaredParams = paramLists.get(0).getParameters();
Parameter lastDeclared = declaredParams.size() > 0 ? declaredParams.get(declaredParams.size() - 1) : null;
boolean boundSequenced = false;
String varBaseName = aliasName("arg");
callVarName = varBaseName + "$callable$";
int numDeclared = declaredParams.size();
int numDeclaredFixed = (lastDeclared != null && lastDeclared.isSequenced()) ? numDeclared - 1 : numDeclared;
int numPassed = namedArguments.size();
int idx = 0;
for (Tree.NamedArgument namedArg : namedArguments) {
at(namedArg);
Tree.Expression expr = ((Tree.SpecifiedArgument)namedArg).getSpecifierExpression().getExpression();
Parameter declaredParam = namedArg.getParameter();
int index;
BoxingStrategy boxType;
ProducedType type;
if (declaredParam != null) {
if (declaredParam.isSequenced()) {
boundSequenced = true;
}
index = declaredParams.indexOf(declaredParam);
boxType = Util.getBoxingStrategy(declaredParam);
type = getTypeForParameter(declaredParam, isRaw, typeArgumentModels);
} else {
// Arguments of overloaded methods don't have a reference to parameter
index = idx++;
boxType = BoxingStrategy.UNBOXED;
type = expr.getTypeModel();
}
String varName = varBaseName + "$" + index;
// if we can't pick up on the type from the declaration, revert to the type of the expression
if(isTypeParameter(type))
type = expr.getTypeModel();
JCExpression typeExpr = makeJavaType(type, (boxType == BoxingStrategy.BOXED) ? TYPE_ARGUMENT : 0);
JCExpression argExpr = transformExpression(expr, boxType, type);
JCVariableDecl varDecl = makeVar(varName, typeExpr, argExpr);
vars.append(varDecl);
}
if (!Decl.isOverloaded(primaryDecl) && numPassed < numDeclaredFixed) {
boolean needsThis = false;
if (Decl.withinClassOrInterface(primaryDecl)) {
// first append $this
ProducedType thisType = getThisType(primaryDecl);
vars.append(makeVar(varBaseName + "$this$", makeJavaType(thisType, NO_PRIMITIVES), makeUnquotedIdent(callVarName)));
needsThis = true;
}
// append any arguments for defaulted parameters
for (int ii = 0; ii < numDeclaredFixed; ii++) {
Parameter param = declaredParams.get(ii);
if (containsParameter(namedArguments, param)) {
continue;
}
String varName = varBaseName + "$" + ii;
String methodName = Util.getDefaultedParamMethodName(primaryDecl, param);
List<JCExpression> arglist = makeThisVarRefArgumentList(varBaseName, ii, needsThis);
JCExpression argExpr;
if (!param.isSequenced()) {
Declaration container = param.getDeclaration().getRefinedDeclaration();
if (!container.isToplevel()) {
container = (Declaration)container.getContainer();
}
String className = Util.getCompanionClassName(container.getName());
argExpr = at(ce).Apply(null, makeQualIdent(makeQualIdentFromString(container.getQualifiedNameString()), className, methodName), arglist);
} else {
argExpr = makeEmpty();
}
BoxingStrategy boxType = Util.getBoxingStrategy(param);
ProducedType type = getTypeForParameter(param, isRaw, typeArgumentModels);
JCExpression typeExpr = makeJavaType(type, (boxType == BoxingStrategy.BOXED) ? TYPE_ARGUMENT : 0);
JCVariableDecl varDecl = makeVar(varName, typeExpr, argExpr);
vars.append(varDecl);
}
}
Tree.SequencedArgument sequencedArgument = ce.getNamedArgumentList().getSequencedArgument();
if (sequencedArgument != null) {
at(sequencedArgument);
String varName = varBaseName + "$" + numDeclaredFixed;
JCExpression typeExpr = makeJavaType(lastDeclared.getType(), AbstractTransformer.WANT_RAW_TYPE);
JCExpression argExpr = makeSequenceRaw(sequencedArgument.getExpressionList().getExpressions());
JCVariableDecl varDecl = makeVar(varName, typeExpr, argExpr);
vars.append(varDecl);
} else if (lastDeclared != null
&& lastDeclared.isSequenced()
&& !boundSequenced) {
String varName = varBaseName + "$" + numDeclaredFixed;
JCExpression typeExpr = makeJavaType(lastDeclared.getType(), AbstractTransformer.WANT_RAW_TYPE);
JCVariableDecl varDecl = makeVar(varName, typeExpr, makeEmpty());
vars.append(varDecl);
}
if (!Decl.isOverloaded(primaryDecl)) {
args.appendList(makeVarRefArgumentList(varBaseName, numDeclared));
} else {
// For overloaded methods (and therefore Java interop) we just pass the arguments we have
args.appendList(makeVarRefArgumentList(varBaseName, numPassed));
}
}
return makeInvocation(ce, vars, args, typeArgs, callVarName);
}
private boolean containsParameter(java.util.List<Tree.NamedArgument> namedArguments, Parameter param) {
for (Tree.NamedArgument namedArg : namedArguments) {
Parameter declaredParam = namedArg.getParameter();
if (param == declaredParam) {
return true;
}
}
return false;
}
// Positional invocation
private JCExpression transformPositionalInvocation(Tree.InvocationExpression ce) {
ListBuffer<JCVariableDecl> vars = null;
ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
Declaration primaryDecl = ce.getPrimary().getDeclaration();
Tree.PositionalArgumentList positional = ce.getPositionalArgumentList();
java.util.List<ProducedType> typeArgumentModels = getTypeArguments(ce);
List<JCExpression> typeArgs = transformTypeArguments(typeArgumentModels);
boolean isRaw = typeArgs.isEmpty();
String callVarName = null;
java.util.List<ParameterList> paramLists = ((Functional)primaryDecl).getParameterLists();
java.util.List<Parameter> declaredParams = paramLists.get(0).getParameters();
int numDeclared = declaredParams.size();
int numPassed = positional.getPositionalArguments().size();
Parameter lastDeclaredParam = declaredParams.isEmpty() ? null : declaredParams.get(declaredParams.size() - 1);
if (lastDeclaredParam != null
&& lastDeclaredParam.isSequenced()
&& positional.getEllipsis() == null // foo(sequence...) syntax => no need to box
&& numPassed >= (numDeclared -1)) {
// => call to a varargs method
// first, append the normal args
for (int ii = 0; ii < numDeclared - 1; ii++) {
Tree.PositionalArgument arg = positional.getPositionalArguments().get(ii);
args.append(transformArg(arg.getExpression(), arg.getParameter(), isRaw, typeArgumentModels));
}
JCExpression boxed;
// then, box the remaining passed arguments
if (numDeclared -1 == numPassed) {
// box as Empty
boxed = makeEmpty();
} else {
// box with an ArraySequence<T>
List<Tree.Expression> x = List.<Tree.Expression>nil();
for (int ii = numDeclared - 1; ii < numPassed; ii++) {
Tree.PositionalArgument arg = positional.getPositionalArguments().get(ii);
x = x.append(arg.getExpression());
}
boxed = makeSequenceRaw(x);
}
args.append(boxed);
} else if (numPassed < numDeclared) {
vars = ListBuffer.lb();
String varBaseName = aliasName("arg");
callVarName = varBaseName + "$callable$";
boolean needsThis = false;
if (Decl.withinClassOrInterface(primaryDecl)) {
// first append $this
ProducedType thisType = getThisType(primaryDecl);
vars.append(makeVar(varBaseName + "$this$", makeJavaType(thisType, NO_PRIMITIVES), makeUnquotedIdent(callVarName)));
needsThis = true;
}
// append the normal args
int idx = 0;
for (Tree.PositionalArgument arg : positional.getPositionalArguments()) {
at(arg);
Tree.Expression expr = arg.getExpression();
Parameter declaredParam = arg.getParameter();
int index;
BoxingStrategy boxType;
ProducedType type;
if (declaredParam != null) {
index = declaredParams.indexOf(declaredParam);
boxType = Util.getBoxingStrategy(declaredParam);
type = getTypeForParameter(declaredParam, isRaw, typeArgumentModels);
} else {
// Arguments of overloaded methods don't have a reference to parameter
index = idx++;
boxType = BoxingStrategy.UNBOXED;
type = expr.getTypeModel();
}
String varName = varBaseName + "$" + index;
// if we can't pick up on the type from the declaration, revert to the type of the expression
if(isTypeParameter(type))
type = expr.getTypeModel();
JCExpression typeExpr = makeJavaType(type, (boxType == BoxingStrategy.BOXED) ? TYPE_ARGUMENT : 0);
JCExpression argExpr = transformExpression(expr, boxType, type);
JCVariableDecl varDecl = makeVar(varName, typeExpr, argExpr);
vars.append(varDecl);
}
if (!Decl.isOverloaded(primaryDecl)) {
// append any arguments for defaulted parameters
for (int ii = numPassed; ii < numDeclared; ii++) {
Parameter param = declaredParams.get(ii);
String varName = varBaseName + "$" + ii;
String methodName = Util.getDefaultedParamMethodName(primaryDecl, param);
List<JCExpression> arglist = makeThisVarRefArgumentList(varBaseName, ii, needsThis);
JCExpression argExpr;
if (!param.isSequenced()) {
Declaration container = param.getDeclaration().getRefinedDeclaration();
if (!container.isToplevel()) {
container = (Declaration)container.getContainer();
}
String className = Util.getCompanionClassName(container.getName());
argExpr = at(ce).Apply(null, makeQualIdent(makeQualIdentFromString(container.getQualifiedNameString()), className, methodName), arglist);
} else {
argExpr = makeEmpty();
}
BoxingStrategy boxType = Util.getBoxingStrategy(param);
ProducedType type = getTypeForParameter(param, isRaw, typeArgumentModels);
JCExpression typeExpr = makeJavaType(type, (boxType == BoxingStrategy.BOXED) ? TYPE_ARGUMENT : 0);
JCVariableDecl varDecl = makeVar(varName, typeExpr, argExpr);
vars.append(varDecl);
}
args.appendList(makeVarRefArgumentList(varBaseName, numDeclared));
} else {
// For overloaded methods (and therefore Java interop) we just pass the arguments we have
args.appendList(makeVarRefArgumentList(varBaseName, numPassed));
}
} else {
// append the normal args
for (Tree.PositionalArgument arg : positional.getPositionalArguments()) {
args.append(transformArg(arg.getExpression(), arg.getParameter(), isRaw, typeArgumentModels));
}
}
return makeInvocation(ce, vars, args, typeArgs, callVarName);
}
// Make a list of $arg0, $arg1, ... , $argN
private List<JCExpression> makeVarRefArgumentList(String varBaseName, int argCount) {
List<JCExpression> names = List.<JCExpression> nil();
for (int i = 0; i < argCount; i++) {
names = names.append(makeUnquotedIdent(varBaseName + "$" + i));
}
return names;
}
// Make a list of $arg$this$, $arg0, $arg1, ... , $argN
private List<JCExpression> makeThisVarRefArgumentList(String varBaseName, int argCount, boolean needsThis) {
List<JCExpression> names = List.<JCExpression> nil();
if (needsThis) {
names = names.append(makeUnquotedIdent(varBaseName + "$this$"));
}
names = names.appendList(makeVarRefArgumentList(varBaseName, argCount));
return names;
}
private JCExpression makeInvocation(
final Tree.InvocationExpression ce,
final ListBuffer<JCVariableDecl> vars,
final ListBuffer<JCExpression> args,
final List<JCExpression> typeArgs,
final String callVarName) {
at(ce);
JCExpression result = transformPrimary(ce.getPrimary(), new TermTransformer() {
@Override
public JCExpression transform(JCExpression primaryExpr, String selector) {
JCExpression actualPrimExpr = null;
if (vars != null && primaryExpr != null && selector != null) {
// Prepare the first argument holding the primary for the call
JCExpression callVarExpr = makeUnquotedIdent(callVarName);
ProducedType type = ((Tree.QualifiedMemberExpression)ce.getPrimary()).getTarget().getQualifyingType();
JCVariableDecl callVar = makeVar(callVarName, makeJavaType(type, NO_PRIMITIVES), primaryExpr);
vars.prepend(callVar);
actualPrimExpr = callVarExpr;
} else {
actualPrimExpr = primaryExpr;
}
JCExpression resultExpr;
if (ce.getPrimary() instanceof Tree.BaseTypeExpression) {
ProducedType classType = (ProducedType)((Tree.BaseTypeExpression)ce.getPrimary()).getTarget();
resultExpr = make().NewClass(null, null, makeJavaType(classType, CLASS_NEW), args.toList(), null);
} else if (ce.getPrimary() instanceof Tree.QualifiedTypeExpression) {
resultExpr = make().NewClass(actualPrimExpr, null, makeQuotedIdent(selector), args.toList(), null);
} else {
resultExpr = make().Apply(typeArgs, makeQualIdent(actualPrimExpr, selector), args.toList());
}
if (vars != null) {
ProducedType returnType = ce.getTypeModel();
if (isVoid(returnType)) {
// void methods get wrapped like (let $arg$1=expr, $arg$0=expr in call($arg$0, $arg$1); null)
return make().LetExpr(vars.toList(), List.<JCStatement>of(make().Exec(resultExpr)), makeNull());
} else {
// all other methods like (let $arg$1=expr, $arg$0=expr in call($arg$0, $arg$1))
return make().LetExpr(vars.toList(), resultExpr);
}
} else {
return resultExpr;
}
}
});
return result;
}
// Invocation helper functions
private java.util.List<ProducedType> getTypeArguments(Tree.InvocationExpression ce) {
if(ce.getPrimary() instanceof Tree.StaticMemberOrTypeExpression){
return ((Tree.StaticMemberOrTypeExpression)ce.getPrimary()).getTypeArguments().getTypeModels();
}
return null;
}
private List<JCExpression> transformTypeArguments(java.util.List<ProducedType> typeArguments) {
List<JCExpression> result = List.<JCExpression> nil();
if(typeArguments != null){
for (ProducedType arg : typeArguments) {
// cancel type parameters and go raw if we can't specify them
if(willEraseToObject(arg)
|| isTypeParameter(arg))
return List.nil();
result = result.append(makeJavaType(arg, AbstractTransformer.TYPE_ARGUMENT));
}
}
return result;
}
// used by ClassDefinitionBuilder too, for super()
JCExpression transformArg(Tree.Term expr, Parameter parameter, boolean isRaw, java.util.List<ProducedType> typeArgumentModels) {
if (parameter != null) {
ProducedType type = getTypeForParameter(parameter, isRaw, typeArgumentModels);
return transformExpression(expr,
Util.getBoxingStrategy(parameter),
type);
} else {
// Overloaded methods don't have a reference to a parameter
// so we have to treat them differently. Also knowing it's
// overloaded we know we're dealing with Java code so we unbox
ProducedType type = expr.getTypeModel();
return transformExpression(expr,
BoxingStrategy.UNBOXED,
type);
}
}
private ProducedType getTypeForParameter(Parameter parameter, boolean isRaw, java.util.List<ProducedType> typeArgumentModels) {
ProducedType type = parameter.getType();
if(isTypeParameter(type)){
TypeParameter tp = (TypeParameter) type.getDeclaration();
if(!isRaw && typeArgumentModels != null){
// try to use the inferred type if we're not going raw
Scope scope = parameter.getContainer();
int typeParamIndex = getTypeParameterIndex(scope, tp);
if(typeParamIndex != -1)
return typeArgumentModels.get(typeParamIndex);
}
if(tp.getSatisfiedTypes().size() >= 1){
// try the first satisfied type
type = tp.getSatisfiedTypes().get(0).getType();
// unless it's erased, in which case try for more specific
if(!willEraseToObject(type))
return type;
}
}
return type;
}
private int getTypeParameterIndex(Scope scope, TypeParameter tp) {
if(scope instanceof Method)
return ((Method)scope).getTypeParameters().indexOf(tp);
return ((ClassOrInterface)scope).getTypeParameters().indexOf(tp);
}
//
// Member expressions
private interface TermTransformer {
JCExpression transform(JCExpression primaryExpr, String selector);
}
// Qualified members
public JCExpression transform(Tree.QualifiedMemberExpression expr) {
return transform(expr, null);
}
private JCExpression transform(Tree.QualifiedMemberExpression expr, TermTransformer transformer) {
JCExpression result;
if (expr.getMemberOperator() instanceof Tree.SafeMemberOp) {
JCExpression primaryExpr = transformQualifiedMemberPrimary(expr);
String tmpVarName = aliasName("safe");
JCExpression typeExpr = makeJavaType(expr.getTarget().getQualifyingType(), NO_PRIMITIVES);
JCExpression transExpr = transformMemberExpression(expr, makeUnquotedIdent(tmpVarName), transformer);
transExpr = boxUnboxIfNecessary(transExpr, expr, expr.getTarget().getType(), BoxingStrategy.BOXED);
JCExpression testExpr = make().Binary(JCTree.NE, makeUnquotedIdent(tmpVarName), makeNull());
JCExpression condExpr = make().Conditional(testExpr, transExpr, makeNull());
result = makeLetExpr(tmpVarName, null, typeExpr, primaryExpr, condExpr);
} else if (expr.getMemberOperator() instanceof Tree.SpreadOp) {
result = transformSpreadOperator(expr, transformer);
} else {
JCExpression primaryExpr = transformQualifiedMemberPrimary(expr);
result = transformMemberExpression(expr, primaryExpr, transformer);
}
return result;
}
private JCExpression transformSpreadOperator(Tree.QualifiedMemberExpression expr, TermTransformer transformer) {
at(expr);
String varBaseName = aliasName("spread");
// sequence
String srcSequenceName = varBaseName+"$0";
ProducedType srcSequenceType = typeFact().getNonemptySequenceType(expr.getPrimary().getTypeModel());
ProducedType srcElementType = typeFact().getElementType(srcSequenceType);
JCExpression srcSequenceTypeExpr = makeJavaType(srcSequenceType, NO_PRIMITIVES);
JCExpression srcSequenceExpr = transformExpression(expr.getPrimary(), BoxingStrategy.BOXED, srcSequenceType);
// reset back here after transformExpression
at(expr);
// size, getSize() always unboxed, but we need to cast to int for Java array access
String sizeName = varBaseName+"$2";
JCExpression sizeType = make().TypeIdent(TypeTags.INT);
JCExpression sizeExpr = make().TypeCast(syms().intType, make().Apply(null,
make().Select(makeUnquotedIdent(srcSequenceName), names().fromString("getSize")),
List.<JCTree.JCExpression>nil()));
// new array
String newArrayName = varBaseName+"$4";
JCExpression arrayElementType = makeJavaType(expr.getTarget().getType(), NO_PRIMITIVES);
JCExpression newArrayType = make().TypeArray(arrayElementType);
JCNewArray newArrayExpr = make().NewArray(arrayElementType, List.of(makeUnquotedIdent(sizeName)), null);
// return the new array
JCExpression returnArrayType = makeJavaType(expr.getTarget().getType(), SATISFIES);
JCExpression returnArrayIdent = make().QualIdent(syms().ceylonArraySequenceType.tsym);
JCExpression returnArrayTypeExpr;
// avoid putting type parameters such as j.l.Object
if(returnArrayType != null)
returnArrayTypeExpr = make().TypeApply(returnArrayIdent, List.of(returnArrayType));
else // go raw
returnArrayTypeExpr = returnArrayIdent;
JCNewClass returnArray = make().NewClass(null, null,
returnArrayTypeExpr,
List.of(makeUnquotedIdent(newArrayName)), null);
// for loop
Name indexVarName = names().fromString(aliasName("index"));
// int index = 0
JCStatement initVarDef = make().VarDef(make().Modifiers(0), indexVarName, make().TypeIdent(TypeTags.INT), makeInteger(0));
List<JCStatement> init = List.of(initVarDef);
// index < size
JCExpression cond = make().Binary(JCTree.LT, make().Ident(indexVarName), makeUnquotedIdent(sizeName));
// index++
JCExpression stepExpr = make().Unary(JCTree.POSTINC, make().Ident(indexVarName));
List<JCExpressionStatement> step = List.of(make().Exec(stepExpr));
// newArray[index]
JCExpression dstArrayExpr = make().Indexed(makeUnquotedIdent(newArrayName), make().Ident(indexVarName));
// srcSequence.item(box(index))
// index is always boxed
JCExpression boxedIndex = boxType(make().Ident(indexVarName), typeFact().getIntegerDeclaration().getType());
JCExpression sequenceItemExpr = make().Apply(null,
make().Select(makeUnquotedIdent(srcSequenceName), names().fromString("item")),
List.<JCExpression>of(boxedIndex));
// item.member
sequenceItemExpr = applyErasureAndBoxing(sequenceItemExpr, srcElementType, true, BoxingStrategy.BOXED,
expr.getTarget().getQualifyingType());
JCExpression appliedExpr = transformMemberExpression(expr, sequenceItemExpr, transformer);
// reset back here after transformMemberExpression
at(expr);
// we always need to box to put in array
appliedExpr = boxUnboxIfNecessary(appliedExpr, expr,
expr.getTarget().getType(), BoxingStrategy.BOXED);
// newArray[index] = box(srcSequence.item(box(index)).member)
JCStatement body = make().Exec(make().Assign(dstArrayExpr, appliedExpr));
// for
JCForLoop forStmt = make().ForLoop(init, cond , step , body);
// build the whole thing
return makeLetExpr(varBaseName,
List.<JCStatement>of(forStmt),
srcSequenceTypeExpr, srcSequenceExpr,
sizeType, sizeExpr,
newArrayType, newArrayExpr,
returnArray);
}
private JCExpression transformQualifiedMemberPrimary(Tree.QualifiedMemberOrTypeExpression expr) {
if(expr.getTarget() == null)
return at(expr).Erroneous(List.<JCTree>nil());
return transformExpression(expr.getPrimary(), BoxingStrategy.BOXED,
expr.getTarget().getQualifyingType());
}
// Base members
public JCExpression transform(Tree.BaseMemberExpression expr) {
return transform(expr, null);
}
private JCExpression transform(Tree.BaseMemberOrTypeExpression expr, TermTransformer transformer) {
return transformMemberExpression(expr, null, transformer);
}
// Type members
public JCExpression transform(Tree.QualifiedTypeExpression expr) {
return transform(expr, null);
}
private JCExpression transform(Tree.QualifiedTypeExpression expr, TermTransformer transformer) {
JCExpression primaryExpr = transformQualifiedMemberPrimary(expr);
return transformMemberExpression(expr, primaryExpr, transformer);
}
// Generic code for all primaries
private JCExpression transformPrimary(Tree.Primary primary, TermTransformer transformer) {
if (primary instanceof Tree.QualifiedMemberExpression) {
return transform((Tree.QualifiedMemberExpression)primary, transformer);
} else if (primary instanceof Tree.BaseMemberExpression) {
return transform((Tree.BaseMemberExpression)primary, transformer);
} else if (primary instanceof Tree.BaseTypeExpression) {
return transform((Tree.BaseTypeExpression)primary, transformer);
} else if (primary instanceof Tree.QualifiedTypeExpression) {
return transform((Tree.QualifiedTypeExpression)primary, transformer);
} else {
return makeUnquotedIdent(primary.getDeclaration().getName());
}
}
private JCExpression transformMemberExpression(Tree.StaticMemberOrTypeExpression expr, JCExpression primaryExpr, TermTransformer transformer) {
JCExpression result = null;
// do not throw, an error will already have been reported
Declaration decl = expr.getDeclaration();
if (decl == null) {
return make().Erroneous(List.<JCTree>nil());
}
// Explanation: primaryExpr and qualExpr both specify what is to come before the selector
// but the important difference is that primaryExpr is used for those situations where
// the result comes from the actual Ceylon code while qualExpr is used for those situations
// where we need to refer to synthetic objects (like wrapper classes for toplevel methods)
JCExpression qualExpr = null;
String selector = null;
if (decl instanceof Getter) {
// invoke the getter
if (decl.isToplevel()) {
primaryExpr = null;
qualExpr = makeQualIdent(makeFQIdent(decl.getContainer().getQualifiedNameString()), Util.quoteIfJavaKeyword(decl.getName()), Util.getGetterName(decl.getName()));
selector = null;
} else if (decl.isClassMember()) {
selector = Util.getGetterName(decl.getName());
} else {
// method local attr
if (!isRecursiveReference(expr)) {
primaryExpr = makeQualIdent(primaryExpr, decl.getName() + "$getter");
}
selector = Util.getGetterName(decl.getName());
}
} else if (decl instanceof Value) {
if (decl.isToplevel()) {
// ERASURE
if ("null".equals(decl.getName())) {
// FIXME this is a pretty brain-dead way to go about erase I think
result = makeNull();
} else if (isBooleanTrue(decl)) {
result = makeBoolean(true);
} else if (isBooleanFalse(decl)) {
result = makeBoolean(false);
} else {
// it's a toplevel attribute
primaryExpr = makeQualIdent(makeFQIdent(decl.getContainer().getQualifiedNameString()), Util.quoteIfJavaKeyword(decl.getName()));
selector = Util.getGetterName(decl.getName());
}
} else if (Decl.isClassAttribute(decl)) {
// invoke the getter
selector = Util.getGetterName(decl.getName());
} else if (decl.isCaptured() || decl.isShared()) {
// invoke the qualified getter
primaryExpr = makeQualIdent(primaryExpr, decl.getName());
selector = Util.getGetterName(decl.getName());
}
} else if (decl instanceof Method) {
if (Decl.withinMethod(decl)) {
java.util.List<String> path = new LinkedList<String>();
if (!isRecursiveReference(expr)) {
path.add(decl.getName());
}
path.add(Util.quoteIfJavaKeyword(decl.getName()));
primaryExpr = null;
qualExpr = makeQualIdent(path);
selector = null;
} else if (decl.isToplevel()) {
java.util.List<String> path = new LinkedList<String>();
// FQN must start with empty ident (see https://github.com/ceylon/ceylon-compiler/issues/148)
if (!decl.getContainer().getQualifiedNameString().isEmpty()) {
path.add("");
path.addAll(Arrays.asList(decl.getContainer().getQualifiedNameString().split("\\.")));
} else {
path.add("");
}
// class
path.add(Util.quoteIfJavaKeyword(decl.getName()));
// method
path.add(Util.quoteIfJavaKeyword(decl.getName()));
primaryExpr = null;
qualExpr = makeQualIdent(path);
selector = null;
} else {
// not toplevel, not within method, must be a class member
selector = Util.quoteMethodName(decl.getName());
}
}
if (result == null) {
boolean useGetter = !(decl instanceof Method);
if (qualExpr == null && selector == null) {
useGetter = decl.isClassOrInterfaceMember() && Util.isErasedAttribute(decl.getName());
if (useGetter) {
selector = Util.quoteMethodName(decl.getName());
} else {
selector = substitute(decl.getName());
}
}
if (qualExpr == null) {
qualExpr = primaryExpr;
}
if (qualExpr == null && needDollarThis && decl.isClassOrInterfaceMember() && expr.getScope() != decl.getContainer()) {
qualExpr = makeUnquotedIdent("$this");
}
if (transformer != null) {
result = transformer.transform(qualExpr, selector);
} else {
result = makeQualIdent(qualExpr, selector);
if (useGetter) {
result = make().Apply(List.<JCTree.JCExpression>nil(),
result,
List.<JCTree.JCExpression>nil());
}
}
}
return result;
}
//
// Array access
public JCTree transform(Tree.IndexExpression access) {
boolean safe = access.getIndexOperator() instanceof Tree.SafeIndexOp;
// depends on the operator
Tree.ElementOrRange elementOrRange = access.getElementOrRange();
if(elementOrRange instanceof Tree.Element){
Tree.Element element = (Tree.Element) elementOrRange;
// let's see what types there are
ProducedType leftType = access.getPrimary().getTypeModel();
if(safe)
leftType = access.getUnit().getDefiniteType(leftType);
ProducedType leftCorrespondenceType = leftType.getSupertype(access.getUnit().getCorrespondenceDeclaration());
ProducedType rightType = getTypeArgument(leftCorrespondenceType, 0);
// do the index
JCExpression index = transformExpression(element.getExpression(), BoxingStrategy.BOXED, rightType);
// look at the lhs
JCExpression lhs = transformExpression(access.getPrimary(), BoxingStrategy.BOXED, leftCorrespondenceType);
if(!safe)
// make a "lhs.item(index)" call
return at(access).Apply(List.<JCTree.JCExpression>nil(),
make().Select(lhs, names().fromString("item")), List.of(index));
// make a (let ArrayElem tmp = lhs in (tmp != null ? tmp.item(index) : null)) call
JCExpression arrayType = makeJavaType(leftCorrespondenceType);
Name varName = names().fromString(tempName("safeaccess"));
// tmpVar.item(index)
JCExpression safeAccess = make().Apply(List.<JCTree.JCExpression>nil(),
make().Select(make().Ident(varName), names().fromString("item")), List.of(index));
at(access.getPrimary());
// (tmpVar != null ? safeAccess : null)
JCConditional conditional = make().Conditional(make().Binary(JCTree.NE, make().Ident(varName), makeNull()),
safeAccess, makeNull());
// ArrayElem tmp = lhs
JCVariableDecl tmpVar = make().VarDef(make().Modifiers(0), varName, arrayType, lhs);
// (let tmpVar in conditional)
return make().LetExpr(tmpVar, conditional);
}else{
// find the types
ProducedType leftType = access.getPrimary().getTypeModel();
ProducedType leftRangedType = leftType.getSupertype(access.getUnit().getRangedDeclaration());
ProducedType rightType = getTypeArgument(leftRangedType, 0);
// look at the lhs
JCExpression lhs = transformExpression(access.getPrimary(), BoxingStrategy.BOXED, leftRangedType);
// do the indices
Tree.ElementRange range = (Tree.ElementRange) elementOrRange;
JCExpression start = transformExpression(range.getLowerBound(), BoxingStrategy.BOXED, rightType);
JCExpression end;
if(range.getUpperBound() != null)
end = transformExpression(range.getUpperBound(), BoxingStrategy.BOXED, rightType);
else
end = makeNull();
// make a "lhs.span(start, end)" call
return at(access).Apply(List.<JCTree.JCExpression>nil(),
make().Select(lhs, names().fromString("span")), List.of(start, end));
}
}
//
// Assignment
public JCExpression transform(Tree.AssignOp op) {
return transformAssignment(op, op.getLeftTerm(), op.getRightTerm());
}
private JCExpression transformAssignment(Node op, Tree.Term leftTerm, Tree.Term rightTerm) {
// FIXME: can this be anything else than a Primary?
TypedDeclaration decl = (TypedDeclaration) ((Tree.Primary)leftTerm).getDeclaration();
// Remember and disable inStatement for RHS
boolean tmpInStatement = inStatement;
inStatement = false;
// right side
final JCExpression rhs = transformExpression(rightTerm, Util.getBoxingStrategy(decl), decl.getType());
if (tmpInStatement) {
return transformAssignment(op, leftTerm, rhs);
} else {
ProducedType valueType = leftTerm.getTypeModel();
return transformAssignAndReturnOperation(op, leftTerm, Util.getBoxingStrategy(decl) == BoxingStrategy.BOXED,
valueType, valueType, new AssignAndReturnOperationFactory(){
@Override
public JCExpression getNewValue(JCExpression previousValue) {
return rhs;
}
});
}
}
private JCExpression transformAssignment(final Node op, Tree.Term leftTerm, JCExpression rhs) {
// left hand side can be either BaseMemberExpression, QualifiedMemberExpression or array access (M2)
// TODO: array access (M2)
JCExpression expr = null;
if(leftTerm instanceof Tree.BaseMemberExpression)
expr = null;
else if(leftTerm instanceof Tree.QualifiedMemberExpression){
Tree.QualifiedMemberExpression qualified = ((Tree.QualifiedMemberExpression)leftTerm);
expr = transformExpression(qualified.getPrimary(), BoxingStrategy.BOXED, qualified.getTarget().getQualifyingType());
}else{
log.error("ceylon", "Not supported yet: "+op.getNodeType());
return at(op).Erroneous(List.<JCTree>nil());
}
return transformAssignment(op, leftTerm, expr, rhs);
}
private JCExpression transformAssignment(Node op, Tree.Term leftTerm, JCExpression lhs, JCExpression rhs) {
JCExpression result = null;
// FIXME: can this be anything else than a Primary?
TypedDeclaration decl = (TypedDeclaration) ((Tree.Primary)leftTerm).getDeclaration();
boolean variable = decl.isVariable();
at(op);
String selector = Util.getSetterName(decl.getName());
if (decl.isToplevel()) {
// must use top level setter
lhs = makeQualIdent(makeFQIdent(decl.getContainer().getQualifiedNameString()), Util.quoteIfJavaKeyword(decl.getName()));
} else if ((decl instanceof Getter)) {
// must use the setter
if (Decl.withinMethod(decl)) {
lhs = makeQualIdent(lhs, decl.getName() + "$setter");
}
} else if (variable && (Decl.isClassAttribute(decl))) {
// must use the setter, nothing to do
} else if (variable && (decl.isCaptured() || decl.isShared())) {
// must use the qualified setter
lhs = makeQualIdent(lhs, decl.getName());
} else {
result = at(op).Assign(makeQualIdent(lhs, decl.getName()), rhs);
}
if (result == null) {
result = make().Apply(List.<JCTree.JCExpression>nil(),
makeQualIdent(lhs, selector),
List.<JCTree.JCExpression>of(rhs));
}
return result;
}
//
// Type helper functions
private ProducedType getSupertype(Tree.Term term, Interface compoundType){
return term.getTypeModel().getSupertype(compoundType);
}
private ProducedType getTypeArgument(ProducedType leftType) {
if (leftType!=null && leftType.getTypeArguments().size()==1) {
return leftType.getTypeArgumentList().get(0);
}
return null;
}
private ProducedType getTypeArgument(ProducedType leftType, int i) {
if (leftType!=null && leftType.getTypeArguments().size() > i) {
return leftType.getTypeArgumentList().get(i);
}
return null;
}
//
// Helper functions
private boolean isRecursiveReference(Tree.StaticMemberOrTypeExpression expr) {
Declaration decl = expr.getDeclaration();
Scope s = expr.getScope();
while (!(s instanceof Declaration) && (s.getContainer() != s)) {
s = s.getContainer();
}
return (s instanceof Declaration) && (s == decl);
}
}
|
[
"yuzhongxing88@gmail.com"
] |
yuzhongxing88@gmail.com
|
04ab9b9347a426f2ace15872fe2fa0a7e910b61e
|
563722ced7f6b875ca044aeb5e07e3ecfb48c982
|
/HealthCare_Android/app/src/test/java/com/ivan/healthcare/healthcare_android/ExampleUnitTest.java
|
c4784e2cbab61685aecc6591c2c9d8dc36f90916
|
[] |
no_license
|
victoriamx/HealthCare
|
1b632059404145964471fbc89e97be46f689aa1c
|
5c1c2d7e4782d8b4a9cdb4dc33c4d5ce7205aecc
|
refs/heads/master
| 2020-04-05T00:19:00.501403
| 2016-05-29T05:47:28
| 2016-05-29T05:47:28
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 331
|
java
|
package com.ivan.healthcare.healthcare_android;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
|
[
"475176416@qq.com"
] |
475176416@qq.com
|
0b2f1a2cc3e38766b0525cfdfeb70e442475801d
|
e9affefd4e89b3c7e2064fee8833d7838c0e0abc
|
/aws-java-sdk-appmesh/src/main/java/com/amazonaws/services/appmesh/model/IpPreference.java
|
9981671d6c2d3ff54ed4271b5269d145d1273a17
|
[
"Apache-2.0"
] |
permissive
|
aws/aws-sdk-java
|
2c6199b12b47345b5d3c50e425dabba56e279190
|
bab987ab604575f41a76864f755f49386e3264b4
|
refs/heads/master
| 2023-08-29T10:49:07.379135
| 2023-08-28T21:05:55
| 2023-08-28T21:05:55
| 574,877
| 3,695
| 3,092
|
Apache-2.0
| 2023-09-13T23:35:28
| 2010-03-22T23:34:58
| null |
UTF-8
|
Java
| false
| false
| 1,849
|
java
|
/*
* Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.appmesh.model;
import javax.annotation.Generated;
/**
*
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public enum IpPreference {
IPv6_PREFERRED("IPv6_PREFERRED"),
IPv4_PREFERRED("IPv4_PREFERRED"),
IPv4_ONLY("IPv4_ONLY"),
IPv6_ONLY("IPv6_ONLY");
private String value;
private IpPreference(String value) {
this.value = value;
}
@Override
public String toString() {
return this.value;
}
/**
* Use this in place of valueOf.
*
* @param value
* real value
* @return IpPreference corresponding to the value
*
* @throws IllegalArgumentException
* If the specified value does not map to one of the known values in this enum.
*/
public static IpPreference fromValue(String value) {
if (value == null || "".equals(value)) {
throw new IllegalArgumentException("Value cannot be null or empty!");
}
for (IpPreference enumEntry : IpPreference.values()) {
if (enumEntry.toString().equals(value)) {
return enumEntry;
}
}
throw new IllegalArgumentException("Cannot create enum from " + value + " value!");
}
}
|
[
""
] | |
92fe6c27cf079880eb3610b221045e26ee6b6c65
|
68650b353b8b39203fdcb5145fec6c8d0dd48c86
|
/app/src/main/java/org/ihsan/android/noline/QueuedState.java
|
5423c7db6df664aef01b120aef9ae9de529c87cf
|
[] |
no_license
|
myihsan/NoLine
|
e1e4e8dfe12afbc20ab23f73fd41467be234315c
|
804acf7a74ea05c715ddfa4145b3942297b1ca2b
|
refs/heads/master
| 2016-09-02T02:48:33.363795
| 2015-05-18T08:10:48
| 2015-05-18T08:10:48
| 34,046,273
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 3,245
|
java
|
package org.ihsan.android.noline;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Created by Ihsan on 15/5/4.
*/
public class QueuedState {
private int mNumber;
private String mQueueName;
private String mSubqueueName;
private String mInTime;
private String mOutTime;
private String mToken;
private int mEstimatedTime;
private String state;
private boolean isFresh;
public QueuedState(JSONObject jsonQueue) throws JSONException {
mNumber = Integer.valueOf(jsonQueue.getString("number"));
mQueueName = jsonQueue.getString("name");
mSubqueueName = jsonQueue.getString("subqueueName");
mInTime = jsonQueue.getString("inTime");
mOutTime = jsonQueue.getString("outTime");
mToken = jsonQueue.getString("token");
String estimatedTime = jsonQueue.getString("estimatedTime");
if (estimatedTime != "null") {
mEstimatedTime = Integer.valueOf(estimatedTime);
} else {
mEstimatedTime = 0;
}
state = jsonQueue.getString("state");
}
public int getNumber() {
return mNumber;
}
public void setNumber(int number) {
mNumber = number;
}
public String getQueueName() {
return mQueueName;
}
public void setQueueName(String queueName) {
mQueueName = queueName;
}
public String getSubqueueName() {
return mSubqueueName;
}
public void setSubqueueName(String subqueueName) {
mSubqueueName = subqueueName;
}
public String getInTime() {
return mInTime;
}
public void setInTime(String inTime) {
mInTime = inTime;
}
public String getOutTime() {
return mOutTime;
}
public void setOutTime(String outTime) {
mOutTime = outTime;
}
public String getToken() {
return mToken;
}
public void setToken(String token) {
mToken = token;
}
public int getEstimatedTime() {
return mEstimatedTime;
}
public void setEstimatedTime(int estimatedTime) {
mEstimatedTime = estimatedTime;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public boolean isFresh() {
return isFresh;
}
public void setIsFresh(boolean isFresh) {
this.isFresh = isFresh;
}
public String getEstimatedTimeString() {
String estimatedTimeString = "预计时间:";
if (mEstimatedTime == -1) {
estimatedTimeString="排队结束";
} else if (mEstimatedTime == 0) {
estimatedTimeString="预计时间:无法计算";
} else {
int hour = mEstimatedTime / 3600;
int minute = (mEstimatedTime - hour * 3600) / 60;
if (hour != 0) {
if (minute != 0) {
estimatedTimeString += hour + "小时" + minute + "分钟";
} else {
estimatedTimeString += hour + "小时";
}
} else {
estimatedTimeString += minute + "分钟";
}
}
return estimatedTimeString;
}
}
|
[
"ihsan.lee@gmail.com"
] |
ihsan.lee@gmail.com
|
13f4ce9cb655ea866c9bf4b262f9e86e491eda48
|
77f32e0a0708f6c5cb94109c45216dbca1791361
|
/Spark-service/service-uum/src/main/java/com/lyc/spark/service/uum/mapper/AuthClientMapper.java
|
68b30f76cb17533d26d27f6e06a33549cbf3794d
|
[] |
no_license
|
Mamba0000/Spark
|
91917e818a1c44d8206b35bd1ae266b7eb436f4b
|
642bd9d7ad39fc55f542a1495da90ed74aaa4800
|
refs/heads/master
| 2023-06-27T13:04:52.312933
| 2021-08-01T06:20:21
| 2021-08-01T06:20:21
| 334,805,247
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 251
|
java
|
package com.lyc.spark.service.uum.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lyc.spark.service.uum.entity.AuthClient;
/**
* Mapper 接口
*
*/
public interface AuthClientMapper extends BaseMapper<AuthClient> {
}
|
[
"306702227@qq.com"
] |
306702227@qq.com
|
52dc95207be0a297d76ac64c5ce415b43bf84377
|
3671bec0bf1f42acec53aafaa5936bc596606efd
|
/src/main/java/de/nikos410/ina/webshop/model/RegisterRequest.java
|
9c14ca4f2981536e53012b3601469ee0fb3d48b7
|
[] |
no_license
|
Nikos410/ina1-exam
|
521c0a98393da7e44c9cf14c868581936f72348f
|
7055ad1037a15f80bf12074db88b0e3b9cf3fe81
|
refs/heads/master
| 2023-06-21T23:36:19.748417
| 2021-07-25T12:04:11
| 2021-07-25T12:04:11
| 387,735,242
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 146
|
java
|
package de.nikos410.ina.webshop.model;
public record RegisterRequest(String username, String password, String fullName, String emailAddress) {
}
|
[
"nikos.epping@protonmail.com"
] |
nikos.epping@protonmail.com
|
abc21bba329fb5434bbacd49e2b8c4d4c4ed63ce
|
bceb7f77071b10ef935e706b02b94e3f57604e43
|
/src/main/java/com/jiujun/voice/modules/apps/user/userinfo/service/impl/UserAlbumServiceImpl.java
|
3c03d194f1fe02cf3190c15ecd07e1f2811d21cb
|
[] |
no_license
|
OnlyJJ/yuyin
|
bde4a58acb87ae24cf857b4d455edfe29b8f9b98
|
56f470b3fd18f1e3f4bf4cefc0aca3992c67cc74
|
refs/heads/master
| 2020-05-04T05:25:57.491586
| 2019-04-02T02:42:20
| 2019-04-02T02:42:20
| 178,985,022
| 3
| 3
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,272
|
java
|
package com.jiujun.voice.modules.apps.user.userinfo.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.jiujun.voice.common.enums.ErrorCode;
import com.jiujun.voice.common.exception.CmdException;
import com.jiujun.voice.modules.apps.user.userinfo.dao.UserAlbumDao;
import com.jiujun.voice.modules.apps.user.userinfo.domain.UserAlbum;
import com.jiujun.voice.modules.apps.user.userinfo.service.UserAlbumService;
/**
*
* @author Coody
*
*/
@Service
public class UserAlbumServiceImpl implements UserAlbumService{
@Resource
UserAlbumDao userAlbumDao;
@Override
public List<UserAlbum> getUserAlbums(String userId) {
return userAlbumDao.getUserAlbums(userId);
}
@Override
public Integer commitUserAlbums(String userId, List<String> imgs) {
List<UserAlbum> userAlbums=getUserAlbums(userId);
if(userAlbums!=null){
if(userAlbums.size()+imgs.size()>9){
throw new CmdException(ErrorCode.ERROR_1043);
}
}
Integer code= userAlbumDao.commitUserAlbums(userId, imgs);
return code;
}
@Override
public Integer delUserAlbums(String userId, List<String> imgs) {
return userAlbumDao.delUserAlbums(userId, imgs);
}
}
|
[
"370083084@qq.com"
] |
370083084@qq.com
|
65a4366c14b6546440d06a3ea39e4482cca17b6a
|
af9eb8041cd78b17b6929f6ee79c59df40a1bbb2
|
/terraform-generator-aws/src/main/java/com/anthunt/terraform/generator/aws/command/CommonArgs.java
|
866a56110c4f6cf7eea03aff8280165409198fbc
|
[
"Apache-2.0"
] |
permissive
|
syllogy/AWS2Terraform
|
aa3df11ef57aa8b319446bc94340a4dfb849f8df
|
4ebaecb9a30e40e6f3e62a791faf02edb9ba51be
|
refs/heads/master
| 2023-07-03T18:58:30.570338
| 2021-07-07T02:34:40
| 2021-07-07T02:34:40
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,909
|
java
|
package com.anthunt.terraform.generator.aws.command;
import com.beust.jcommander.Parameter;
import lombok.Data;
@Data
public class CommonArgs {
private static final String DEFAULT_PROFILE = "default";
private static final String PROFILE_HELP = "aws profile name by ~/.aws/credentials and config ex) default";
private static final String REGION_HELP = "aws region id ex) us-east-1";
private static final boolean DEFAULT_EXPLICIT = true;
private static final String EXPLICIT_HELP = "explicit output files by terraform types. - default: " + DEFAULT_EXPLICIT;
@Parameter(names = {"help"}, description = "display usage informations.", help = true)
private boolean isHelp = false;
@Parameter(names = {"-P", "--profile"}, description = CommonArgs.PROFILE_HELP, required = true)
private String profile;
@Parameter(names = {"-R", "--region"}, description = CommonArgs.REGION_HELP, required = true)
private String region;
@Parameter(names = {"-E", "--explicit"}, description = CommonArgs.EXPLICIT_HELP)
private boolean isExplicit = CommonArgs.DEFAULT_EXPLICIT;
@Parameter(names = {"--dir"}, description = "output terraform file directory path")
private String outputDirPath = "output";
@Parameter(names = {"--provider-file-name"}, description = "provider.tf will be generate with name <provider file name>.tf")
private String providerFileName = "provider.tf";
@Parameter(names = {"--resource-file-name"}, description = "terraform resources file name will be generate with name <resource file name>.tf")
private String resourceFileName = "main.tf";
@Parameter(names = {"-S", "--silence"}, description = "no stdout.")
private boolean isSilence = true;
@Parameter(names = {"-D", "--delete-output-directory"}, description = "delete output directory before generate.")
private boolean isDeleteOutputDirectory = true;
}
|
[
"anthunt01@gmail.com"
] |
anthunt01@gmail.com
|
a320b93bad2f330716037d81cb9887ad2fcf0516
|
9d14214cc986ae372f5511cb5d45611cc91220b6
|
/Java/Algorithms/TuringMachineApplet/TuringMachineApplet.java
|
faf60e2cc7ddcaa6b94c9c0050d8f7d6c263e26b
|
[] |
no_license
|
una1veritas/Workspace
|
6849309b908810042756640e3b02ad6716c3dc9c
|
32de11bec1755fdbe94885cd12688c3977c65d3a
|
refs/heads/master
| 2023-08-31T05:58:16.708401
| 2023-08-24T07:11:36
| 2023-08-24T07:11:36
| 5,622,781
| 2
| 0
| null | 2017-09-04T11:31:25
| 2012-08-31T00:31:33
|
C
|
UTF-8
|
Java
| false
| false
| 3,297
|
java
|
// Decompiled by Jad v1.5.7d. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3)
// Source File Name: xTuringMachineApplet.java
//package tm;
import java.applet.Applet;
import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Vector;
//import TuringMachinePanel;
public class TuringMachineApplet extends Applet {
public String getAppletInfo() {
return "xTuringMachine, by David J. Eck (eck@hws.edu), Version 1.0 August 1997.";
}
public String[][] getParameterInfo() {
return parameterInfo;
}
public void init() {
setBackground(Color.lightGray);
setLayout(new BorderLayout());
Object aobj[] = getURLs();
if(aobj == null)
TMpanel = new TuringMachinePanel(null, null);
else
TMpanel = new TuringMachinePanel((URL[])aobj[0], (String[])aobj[1]);
add("Center", TMpanel);
}
public void start() {
TMpanel.start();
}
public void stop() {
TMpanel.stop();
}
public void destroy() {
TMpanel.destroy();
}
Object[] getURLs() {
int i = 0;
Vector vector = new Vector();
Vector vector1 = new Vector();
String s = getParameter("BASE");
URL url;
if(s == null)
url = getDocumentBase();
else
try
{
url = new URL(getDocumentBase(), s);
}
catch(MalformedURLException _ex)
{
return null;
}
String s1 = getParameter("URL");
do
{
if(s1 != null)
{
URL url1;
try
{
url1 = new URL(url, s1);
}
catch(MalformedURLException _ex)
{
continue;
}
vector.addElement(url1);
vector1.addElement(s1);
}
i++;
s1 = getParameter("URL" + i);
} while(s1 != null);
if(vector.size() > 0)
{
URL aurl[] = new URL[vector.size()];
String as[] = new String[vector.size()];
for(int j = 0; j < aurl.length; j++)
{
aurl[j] = (URL)vector.elementAt(j);
as[j] = (String)vector1.elementAt(j);
}
Object aobj[] = new Object[2];
aobj[0] = aurl;
aobj[1] = as;
return aobj;
} else
{
return null;
}
}
// public TuringMachineApplet()
// {
// }
TuringMachinePanel TMpanel;
String parameterInfo[][] = {
{
"URL", "url", "absolute or relative url of a text file containing a sample xTuringMachine program"
}, {
"URL1,URL2,...", "url", "additional URLs of xTTuringMachine programs"
}, {
"BASE", "url", "base url for interpreting URL, URL1, ...; if not given, document base is used"
}
};
}
|
[
"una.veritas@icloud.com"
] |
una.veritas@icloud.com
|
6e85ae0ea8115e21614dbc22f06b90440c18f540
|
0501a01388f9e7a860445deffcda745a3da2286a
|
/core/src/com/singaporetech/eod/CollisionEngine.java
|
0d3aa9968a5a12d178c6dc84f72d554e40984571
|
[] |
no_license
|
TheDarkMew/eod
|
232c84fa7a50457078283a81c2298c35ab0183ea
|
501155000f4f52518fd7477d9ffd7335659eb31d
|
refs/heads/master
| 2023-03-21T19:05:27.465611
| 2021-03-19T04:06:05
| 2021-03-19T04:06:05
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 3,151
|
java
|
package com.singaporetech.eod;
import com.badlogic.gdx.math.Vector2;
import com.singaporetech.eod.components.collision.Collidable;
import com.singaporetech.eod.components.collision.Collider;
import java.util.LinkedList;
import java.util.List;
/**
* Created by mrboliao on 24/1/17.
* NOTE THAT THIS IS LEGACY CODE THAT HAS NO PROPER COMMENTS
*/
public class CollisionEngine implements Engine {
private List<com.singaporetech.eod.components.collision.Collidable> collidables = new LinkedList<com.singaporetech.eod.components.collision.Collidable>();
private static CollisionEngine instance = new CollisionEngine();
public static CollisionEngine i(){
return instance;
}
private CollisionEngine() {}
public void tick() {
// do collision responses to prevent overlapping objects
// todo: quadtrees when things grow big
/*
for (Collidable c1: collidables) {
for (Collidable c2: collidables) {
if (c1 != c2 && c2.isStatic()) {
c1.checkCollisionAndRespond(c2);
}
}
}
*/
}
@Override
public void init() {
}
/**
* Check if collider has collided with any other collidables
* @param collider
* @return
*/
public Vector2 getCollisionNorm(com.singaporetech.eod.components.collision.Collider collider) {
for (com.singaporetech.eod.components.collision.Collidable c: collidables) {
if (!collider.equals((com.singaporetech.eod.components.collision.Collider)c) && c.isCollidable()) {
Vector2 collisionNorm = collider.getCollisionNorm(c);
if (collisionNorm != null) {
return collisionNorm;
}
}
}
return null;
}
/**
* Get a new target offset from the obstacle, for steering purposes
* @param collider
* @return
*/
public Vector2 getCollisionAvoidTarget(com.singaporetech.eod.components.collision.Collider collider) {
for (com.singaporetech.eod.components.collision.Collidable c: collidables) {
if (!collider.equals((Collider)c) && c.isCollidable()) {
Vector2 target = collider.getCollisionAvoidTarget(c);
if (target != null) {
return target;
}
}
}
return null;
}
public GameObject getObjectCollidedWithPos(Vector2 pos){
for (com.singaporetech.eod.components.collision.Collidable c:collidables) {
if (c.collidedWithPos(pos)) {
return c.getOwner();
}
}
return null;
}
public boolean isFreeOfCollisions(Vector2 pos) {
return (getObjectCollidedWithPos(pos) == null);
}
public void addCollidable(com.singaporetech.eod.components.collision.Collidable c) {
collidables.add(c);
}
public void removeCollidable(Collidable c) {
collidables.remove(c);
}
public void clearCollidables() {
collidables.clear();
}
@Override
public void finalize() {
}
}
|
[
"chek@gamesstudio.org"
] |
chek@gamesstudio.org
|
ab1697c3b6d64c817ad49f8e07262b930337b5f0
|
6803987319036e73f92429e357aa3ab8b49c3392
|
/struts2/plugins/javatemplates/src/main/java/org/apache/struts2/views/java/simple/CheckboxListHandler.java
|
42807777722b90f5a9e3cec5919e921379748aa4
|
[] |
no_license
|
oliverswan/OpenSourceReading
|
8705eac278c3b73426f6d08fc41d14e245b3b97c
|
30f5ae445dc1ca64b071dc2f5d3bb5b963a5e705
|
refs/heads/master
| 2022-10-27T20:34:16.228853
| 2012-11-03T01:18:13
| 2012-11-03T01:18:13
| 5,302,570
| 0
| 1
| null | 2022-10-04T23:36:00
| 2012-08-05T10:19:28
|
Java
|
UTF-8
|
Java
| false
| false
| 4,270
|
java
|
/*
* $Id: CheckboxListHandler.java 1292705 2012-02-23 08:40:53Z lukaszlenart $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.views.java.simple;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.util.MakeIterator;
import org.apache.struts2.views.java.Attributes;
import org.apache.struts2.views.java.TagGenerator;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
public class CheckboxListHandler extends AbstractTagHandler implements TagGenerator {
public void generate() throws IOException {
Map<String, Object> params = context.getParameters();
//Get parameters
Object listObj = params.get("list");
String listKey = (String) params.get("listKey");
String listValue = (String) params.get("listValue");
String name = (String) params.get("name");
Object disabled = params.get("disabled");
String id = (String) params.get("id");
int cnt = 1;
//This will interate through all lists
ValueStack stack = this.context.getStack();
if (listObj != null) {
Iterator itt = MakeIterator.convert(listObj);
while (itt.hasNext()) {
Object item = itt.next();
stack.push(item);
//key
Object itemKey = findValue(listKey != null ? listKey : "top");
String itemKeyStr = StringUtils.defaultString(itemKey == null ? null : itemKey.toString());
//value
Object itemValue = findValue(listValue != null ? listValue : "top");
String itemValueStr = StringUtils.defaultString(itemValue == null ? null : itemValue.toString());
//Checkbox button section
Attributes a = new Attributes();
a.add("type", "checkbox")
.add("name", name)
.add("value", itemKeyStr)
.addIfTrue("checked", params.get("nameValue"))
.addIfTrue("readonly", params.get("readonly"))
.addIfTrue("disabled", disabled)
.addIfExists("tabindex", params.get("tabindex"))
.addIfExists("id", name + "-" + Integer.toString(cnt++));
start("input", a);
end("input");
//Label section
a = new Attributes();
a.add("for",id)
.addIfExists("class", params.get("cssClass"))
.addIfExists("style", params.get("cssStyle"));
super.start("label", a);
if (StringUtils.isNotEmpty(itemValueStr))
characters(itemValueStr);
super.end("label");
//Hidden input section
a = new Attributes();
a.add("type", "hidden")
.add("id", "__multiselect_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(id)))
.add("name", "__multiselect_" + StringUtils.defaultString(StringEscapeUtils.escapeHtml4(name)))
.add("value", "")
.addIfTrue("disabled", disabled);
start("input", a);
end("input");
stack.pop();
}
}
}
}
|
[
"li.fu@agree.com.cn"
] |
li.fu@agree.com.cn
|
808881545c93a3bedca16fac63d5defa9e8a96d6
|
fa91450deb625cda070e82d5c31770be5ca1dec6
|
/Diff-Raw-Data/23/23_4150a9a63b905c1e366e45fdd069c297614bc2fb/HulaConditionalTree/23_4150a9a63b905c1e366e45fdd069c297614bc2fb_HulaConditionalTree_t.java
|
a2cdab6a7a0c4708bdcc525fa16e239e075dc586
|
[] |
no_license
|
zhongxingyu/Seer
|
48e7e5197624d7afa94d23f849f8ea2075bcaec0
|
c11a3109fdfca9be337e509ecb2c085b60076213
|
refs/heads/master
| 2023-07-06T12:48:55.516692
| 2023-06-22T07:55:56
| 2023-06-22T07:55:56
| 259,613,157
| 6
| 2
| null | 2023-06-22T07:55:57
| 2020-04-28T11:07:49
| null |
UTF-8
|
Java
| false
| false
| 14,533
|
java
|
// $ANTLR 3.5 com/hula/lang/conditional/HulaConditionalTree.g 2013-04-11 11:05:23
package com.hula.lang.conditional;
import com.hula.lang.runtime.RuntimeConnector;
import java.math.BigDecimal;
import org.antlr.runtime.*;
import org.antlr.runtime.tree.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
/**
* Copyright 2013 Simon Curd <simoncurd@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@SuppressWarnings("all")
public class HulaConditionalTree extends TreeParser {
public static final String[] tokenNames = new String[] {
"<invalid>", "<EOR>", "<DOWN>", "<UP>", "BOOLEAN", "IDENT", "NUMBER",
"PROPERTYNAME", "STRING", "WS", "'!='", "'('", "')'", "'<'", "'<='", "'='",
"'>'", "'>='", "'AND'", "'OR'"
};
public static final int EOF=-1;
public static final int T__10=10;
public static final int T__11=11;
public static final int T__12=12;
public static final int T__13=13;
public static final int T__14=14;
public static final int T__15=15;
public static final int T__16=16;
public static final int T__17=17;
public static final int T__18=18;
public static final int T__19=19;
public static final int BOOLEAN=4;
public static final int IDENT=5;
public static final int NUMBER=6;
public static final int PROPERTYNAME=7;
public static final int STRING=8;
public static final int WS=9;
// delegates
public TreeParser[] getDelegates() {
return new TreeParser[] {};
}
// delegators
public HulaConditionalTree(TreeNodeStream input) {
this(input, new RecognizerSharedState());
}
public HulaConditionalTree(TreeNodeStream input, RecognizerSharedState state) {
super(input, state);
}
@Override public String[] getTokenNames() { return HulaConditionalTree.tokenNames; }
@Override public String getGrammarFileName() { return "com/hula/lang/conditional/HulaConditionalTree.g"; }
private ThreadLocal<RuntimeConnector> rcContainer = new ThreadLocal<RuntimeConnector>();
public void setRuntimeConnector(RuntimeConnector connector)
{
rcContainer.set(connector);
}
private RuntimeConnector getRuntimeConnector()
{
return rcContainer.get();
}
// $ANTLR start "test"
// com/hula/lang/conditional/HulaConditionalTree.g:46:1: test returns [Object result] : e= expression EOF ;
public final Object test() throws RecognitionException {
Object result = null;
Object e =null;
try {
// com/hula/lang/conditional/HulaConditionalTree.g:47:2: (e= expression EOF )
// com/hula/lang/conditional/HulaConditionalTree.g:47:4: e= expression EOF
{
pushFollow(FOLLOW_expression_in_test58);
e=expression();
state._fsp--;
match(input,EOF,FOLLOW_EOF_in_test60);
result = e;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return result;
}
// $ANTLR end "test"
// $ANTLR start "expression"
// com/hula/lang/conditional/HulaConditionalTree.g:50:1: expression returns [Object result] : ( ^( 'AND' op1= expression op2= expression ) | ^( 'OR' op1= expression op2= expression ) | ^( '=' op1= expression op2= expression ) | ^( '>' op1= expression op2= expression ) | ^( '<' op1= expression op2= expression ) | ^( '>=' op1= expression op2= expression ) | ^( '<=' op1= expression op2= expression ) | ^( '!=' op1= expression op2= expression ) | IDENT | STRING | NUMBER | BOOLEAN );
public final Object expression() throws RecognitionException {
Object result = null;
CommonTree IDENT1=null;
CommonTree STRING2=null;
CommonTree NUMBER3=null;
CommonTree BOOLEAN4=null;
Object op1 =null;
Object op2 =null;
try {
// com/hula/lang/conditional/HulaConditionalTree.g:51:2: ( ^( 'AND' op1= expression op2= expression ) | ^( 'OR' op1= expression op2= expression ) | ^( '=' op1= expression op2= expression ) | ^( '>' op1= expression op2= expression ) | ^( '<' op1= expression op2= expression ) | ^( '>=' op1= expression op2= expression ) | ^( '<=' op1= expression op2= expression ) | ^( '!=' op1= expression op2= expression ) | IDENT | STRING | NUMBER | BOOLEAN )
int alt1=12;
switch ( input.LA(1) ) {
case 18:
{
alt1=1;
}
break;
case 19:
{
alt1=2;
}
break;
case 15:
{
alt1=3;
}
break;
case 16:
{
alt1=4;
}
break;
case 13:
{
alt1=5;
}
break;
case 17:
{
alt1=6;
}
break;
case 14:
{
alt1=7;
}
break;
case 10:
{
alt1=8;
}
break;
case IDENT:
{
alt1=9;
}
break;
case STRING:
{
alt1=10;
}
break;
case NUMBER:
{
alt1=11;
}
break;
case BOOLEAN:
{
alt1=12;
}
break;
default:
NoViableAltException nvae =
new NoViableAltException("", 1, 0, input);
throw nvae;
}
switch (alt1) {
case 1 :
// com/hula/lang/conditional/HulaConditionalTree.g:51:4: ^( 'AND' op1= expression op2= expression )
{
match(input,18,FOLLOW_18_in_expression79);
match(input, Token.DOWN, null);
pushFollow(FOLLOW_expression_in_expression83);
op1=expression();
state._fsp--;
pushFollow(FOLLOW_expression_in_expression87);
op2=expression();
state._fsp--;
match(input, Token.UP, null);
result = OperatorUtil.testAND(op1, op2, getRuntimeConnector());
}
break;
case 2 :
// com/hula/lang/conditional/HulaConditionalTree.g:52:4: ^( 'OR' op1= expression op2= expression )
{
match(input,19,FOLLOW_19_in_expression96);
match(input, Token.DOWN, null);
pushFollow(FOLLOW_expression_in_expression100);
op1=expression();
state._fsp--;
pushFollow(FOLLOW_expression_in_expression104);
op2=expression();
state._fsp--;
match(input, Token.UP, null);
result = OperatorUtil.testOR(op1, op2, getRuntimeConnector());
}
break;
case 3 :
// com/hula/lang/conditional/HulaConditionalTree.g:53:4: ^( '=' op1= expression op2= expression )
{
match(input,15,FOLLOW_15_in_expression113);
match(input, Token.DOWN, null);
pushFollow(FOLLOW_expression_in_expression117);
op1=expression();
state._fsp--;
pushFollow(FOLLOW_expression_in_expression121);
op2=expression();
state._fsp--;
match(input, Token.UP, null);
result = OperatorUtil.testEquals(op1, op2, getRuntimeConnector());
}
break;
case 4 :
// com/hula/lang/conditional/HulaConditionalTree.g:54:4: ^( '>' op1= expression op2= expression )
{
match(input,16,FOLLOW_16_in_expression130);
match(input, Token.DOWN, null);
pushFollow(FOLLOW_expression_in_expression134);
op1=expression();
state._fsp--;
pushFollow(FOLLOW_expression_in_expression138);
op2=expression();
state._fsp--;
match(input, Token.UP, null);
result = OperatorUtil.testGreaterThan(op1, op2, getRuntimeConnector());
}
break;
case 5 :
// com/hula/lang/conditional/HulaConditionalTree.g:55:4: ^( '<' op1= expression op2= expression )
{
match(input,13,FOLLOW_13_in_expression147);
match(input, Token.DOWN, null);
pushFollow(FOLLOW_expression_in_expression151);
op1=expression();
state._fsp--;
pushFollow(FOLLOW_expression_in_expression155);
op2=expression();
state._fsp--;
match(input, Token.UP, null);
result = OperatorUtil.testLessThan(op1, op2, getRuntimeConnector());
}
break;
case 6 :
// com/hula/lang/conditional/HulaConditionalTree.g:56:4: ^( '>=' op1= expression op2= expression )
{
match(input,17,FOLLOW_17_in_expression164);
match(input, Token.DOWN, null);
pushFollow(FOLLOW_expression_in_expression168);
op1=expression();
state._fsp--;
pushFollow(FOLLOW_expression_in_expression172);
op2=expression();
state._fsp--;
match(input, Token.UP, null);
result = OperatorUtil.testGreaterThanEqualTo(op1, op2, getRuntimeConnector());
}
break;
case 7 :
// com/hula/lang/conditional/HulaConditionalTree.g:57:4: ^( '<=' op1= expression op2= expression )
{
match(input,14,FOLLOW_14_in_expression181);
match(input, Token.DOWN, null);
pushFollow(FOLLOW_expression_in_expression185);
op1=expression();
state._fsp--;
pushFollow(FOLLOW_expression_in_expression189);
op2=expression();
state._fsp--;
match(input, Token.UP, null);
result = OperatorUtil.testLessThanEqualTo(op1, op2, getRuntimeConnector());
}
break;
case 8 :
// com/hula/lang/conditional/HulaConditionalTree.g:58:4: ^( '!=' op1= expression op2= expression )
{
match(input,10,FOLLOW_10_in_expression198);
match(input, Token.DOWN, null);
pushFollow(FOLLOW_expression_in_expression202);
op1=expression();
state._fsp--;
pushFollow(FOLLOW_expression_in_expression206);
op2=expression();
state._fsp--;
match(input, Token.UP, null);
result = OperatorUtil.testNotEquals(op1, op2, getRuntimeConnector());
}
break;
case 9 :
// com/hula/lang/conditional/HulaConditionalTree.g:59:4: IDENT
{
IDENT1=(CommonTree)match(input,IDENT,FOLLOW_IDENT_in_expression214);
result = new VariableReference((IDENT1!=null?IDENT1.getText():null));
}
break;
case 10 :
// com/hula/lang/conditional/HulaConditionalTree.g:60:4: STRING
{
STRING2=(CommonTree)match(input,STRING,FOLLOW_STRING_in_expression221);
result = new String((STRING2!=null?STRING2.getText():null));
}
break;
case 11 :
// com/hula/lang/conditional/HulaConditionalTree.g:61:4: NUMBER
{
NUMBER3=(CommonTree)match(input,NUMBER,FOLLOW_NUMBER_in_expression228);
result = new BigDecimal((NUMBER3!=null?NUMBER3.getText():null));
}
break;
case 12 :
// com/hula/lang/conditional/HulaConditionalTree.g:62:4: BOOLEAN
{
BOOLEAN4=(CommonTree)match(input,BOOLEAN,FOLLOW_BOOLEAN_in_expression235);
result = new Boolean((BOOLEAN4!=null?BOOLEAN4.getText():null));
}
break;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
// do for sure before leaving
}
return result;
}
// $ANTLR end "expression"
// Delegated rules
public static final BitSet FOLLOW_expression_in_test58 = new BitSet(new long[]{0x0000000000000000L});
public static final BitSet FOLLOW_EOF_in_test60 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_18_in_expression79 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_expression_in_expression83 = new BitSet(new long[]{0x00000000000FE570L});
public static final BitSet FOLLOW_expression_in_expression87 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_19_in_expression96 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_expression_in_expression100 = new BitSet(new long[]{0x00000000000FE570L});
public static final BitSet FOLLOW_expression_in_expression104 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_15_in_expression113 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_expression_in_expression117 = new BitSet(new long[]{0x00000000000FE570L});
public static final BitSet FOLLOW_expression_in_expression121 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_16_in_expression130 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_expression_in_expression134 = new BitSet(new long[]{0x00000000000FE570L});
public static final BitSet FOLLOW_expression_in_expression138 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_13_in_expression147 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_expression_in_expression151 = new BitSet(new long[]{0x00000000000FE570L});
public static final BitSet FOLLOW_expression_in_expression155 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_17_in_expression164 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_expression_in_expression168 = new BitSet(new long[]{0x00000000000FE570L});
public static final BitSet FOLLOW_expression_in_expression172 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_14_in_expression181 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_expression_in_expression185 = new BitSet(new long[]{0x00000000000FE570L});
public static final BitSet FOLLOW_expression_in_expression189 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_10_in_expression198 = new BitSet(new long[]{0x0000000000000004L});
public static final BitSet FOLLOW_expression_in_expression202 = new BitSet(new long[]{0x00000000000FE570L});
public static final BitSet FOLLOW_expression_in_expression206 = new BitSet(new long[]{0x0000000000000008L});
public static final BitSet FOLLOW_IDENT_in_expression214 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_STRING_in_expression221 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_NUMBER_in_expression228 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_BOOLEAN_in_expression235 = new BitSet(new long[]{0x0000000000000002L});
}
|
[
"yuzhongxing88@gmail.com"
] |
yuzhongxing88@gmail.com
|
68cd9d644fb02a82efa8b57a9224f6f54f973c27
|
a126cd20139144ffd734f4f6f159893c30290374
|
/src/tests/CAUnitModelTest.java
|
582bbd8d8865019c039a80cdc7a25d3c2fadf9ba
|
[] |
no_license
|
bchappet/dnfsim
|
02bb1b4a4d5f0daa41625e698edb6fd332b6f38b
|
d3d15c6f4d3af8b6b2d03352fb84c73dbe08e2a4
|
refs/heads/master
| 2021-01-11T03:59:21.962144
| 2016-10-18T16:19:41
| 2016-10-18T16:19:41
| 71,267,847
| 1
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,320
|
java
|
package tests;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import junit.framework.TestCase;
import maps.Leaf;
import maps.Map;
import maps.Matrix;
import maps.NeighborhoodMap;
import maps.UnitLeaf;
import maps.Var;
import neigborhood.Neighborhood;
import neigborhood.V4Neighborhood2D;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import utils.ArrayUtils;
import utils.Hardware;
import cellularAutomata.CACellUnitModel;
import coordinates.DefaultRoundedSpace;
import coordinates.Space;
public class CAUnitModelTest extends TestCase{
private CACellUnitModel caum;
private NeighborhoodMap map;
@Before
public void setUp() throws Exception {
Var dt = new Var("dt",0.1);
boolean wrap = true;
Var res = new Var("res",8);
Space space = new DefaultRoundedSpace(res, 2, wrap);
// double[] rules = {
// 5,43,27,6,13,57,57,38,
// 59,21,61,10,32,25,0,37,
// 14,46,37,29,25,31,52,52,
// 34,61,44,43,4,63,46,2,
// 6,2,3,51,59,54,42,12,
// 47,61,63,36,33,24,45,5,
// 54,53,37,7,59,15,60,36,
// 55,28,25,19,44,22,49,39
// };
double[] rules = {
35,15,15,35,47,17,58,46,
27,37,30,41,56,39,23,60,
60,17,23,29,29,10,26,43,
61,36,57,62,25,41,42,13,
29,50,4,9,63,39,26,52,
6,52,58,5,28,11,54,21,
31,60,11,35,43,46,29,52,
30,20,19,38,6,22,41,31
};
Matrix rulesMat = new Matrix("RulesMat",dt , space, rules);
caum = new CACellUnitModel(new Var("dt",0.1), space,rulesMat);
map = new NeighborhoodMap("CAMap", caum);
map.addNeighboors(new V4Neighborhood2D(space, new UnitLeaf(map)));
map.constructMemory();
map.toParallel();
}
@After
public void tearDown() throws Exception {
}
@Test
public void testCompute(){
map.setIndex(0,1d);
System.out.println(map.display2D());
map.compute();
System.out.println(map.display2D());
map.compute();
System.out.println(map.display2D());
map.compute();
System.out.println(map.display2D());
map.compute();
System.out.println(map.display2D());
}
@Test
public void testRuleToArray() {
int[] res = Hardware.toVector(20,6);
assertTrue(Arrays.equals(res,ArrayUtils.reverse(new int[]{0,1,0,1,0,0})));
res = Hardware.toVector(62,6);
assertTrue(Arrays.equals(res,ArrayUtils.reverse(new int[]{1,1,1,1,1,0})));
}
}
|
[
"benoit.chappet-de-vangel@inria.fr"
] |
benoit.chappet-de-vangel@inria.fr
|
74c73d19a820081febd0ed235f8bca0476bca9a5
|
1b50b2c191905b0225413c8725ecdf6260f2bb86
|
/src/com/flying/xiao/fragment/CommunityFragment.java
|
ff80eebad03e4a2e0e3dec368fcd2fe799be5e68
|
[
"Apache-2.0"
] |
permissive
|
02110917/Xiao
|
53c1f43f1668a8756baf85ca02bdd4170c8cc5f6
|
3fda0df34bdb40f47cf0f0d0e7c94d8c056cb1ea
|
refs/heads/master
| 2020-12-30T11:14:50.276480
| 2014-08-04T15:22:04
| 2014-08-04T15:22:04
| 22,347,732
| 0
| 1
| null | null | null | null |
WINDOWS-1252
|
Java
| false
| false
| 3,246
|
java
|
package com.flying.xiao.fragment;
import java.util.ArrayList;
import java.util.List;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import com.flying.xiao.R;
import com.flying.xiao.adapter.MyFragmentPaperAdapter;
import com.flying.xiao.constant.Constant;
/**
* ÉçÇø
* @author zhangmin
*
*/
public class CommunityFragment extends Fragment
{
private ViewPager mViewPaper;
private List<Fragment> mFragmentList ;
private Button mBtnDepartment ;
private Button mBtnBusiness ;
@Override
public void onCreate(Bundle savedInstanceState)
{
mFragmentList=new ArrayList<Fragment>();
Fragment fragment=new CommunityFragmentTab();
Fragment fragment1=new CommunityFragmentTab();
((CommunityFragmentTab)fragment).setType(Constant.UserType.User_TYPE_DEPARTMENT);
((CommunityFragmentTab)fragment1).setType(Constant.UserType.User_TYPE_BUSINESS);
mFragmentList.add(fragment);
mFragmentList.add(fragment1);
super.onCreate(savedInstanceState);
System.out.println("CommunityFragment onCreate");
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v=inflater.inflate(R.layout.frame_community, null);
initView(v);
System.out.println("CommunityFragment onCreateView");
return v;
}
@Override
public void onPause()
{
System.out.println("CommunityFragment onPause");
super.onPause();
}
@Override
public void onResume()
{
System.out.println("CommunityFragment onResume");
super.onResume();
}
private void initView(View v){
mViewPaper=(ViewPager)v.findViewById(R.id.viewpager);
mBtnDepartment=(Button)v.findViewById(R.id.frame_btn_main_community_department);
mBtnBusiness=(Button)v.findViewById(R.id.frame_btn_main_community_business);
mBtnDepartment.setEnabled(false);
mBtnDepartment.setOnClickListener(new MyOnClickListener());
mBtnBusiness.setOnClickListener(new MyOnClickListener());
mBtnDepartment.setTag(0);
mBtnBusiness.setTag(1);
MyFragmentPaperAdapter adapter=new MyFragmentPaperAdapter(getChildFragmentManager(), mFragmentList);
mViewPaper.setAdapter(adapter);
mViewPaper.setCurrentItem(0);
mViewPaper.setOnPageChangeListener(new OnPageChangeListener()
{
@Override
public void onPageSelected(int arg0)
{
mBtnBusiness.setEnabled(!mBtnBusiness.isEnabled());
mBtnDepartment.setEnabled(!mBtnDepartment.isEnabled());
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2)
{
}
@Override
public void onPageScrollStateChanged(int arg0)
{
}
});
}
private class MyOnClickListener implements OnClickListener
{
@Override
public void onClick(View v)
{
if((Integer)v.getTag()==0){
mBtnDepartment.setEnabled(true);
mBtnBusiness.setEnabled(false);
mViewPaper.setCurrentItem(0);
}else{
mBtnDepartment.setEnabled(false);
mBtnBusiness.setEnabled(true);
mViewPaper.setCurrentItem(1);
}
}
}
}
|
[
"546107362@qq.com"
] |
546107362@qq.com
|
2bd62fff197b562c0e74f5a6eb7dee771b3e4d7e
|
5a8dc007eea999546d1c403ad95a8edfc7b9bc3c
|
/DesignPattern/src/main/java/orz/an/design/pattern/base/lsv/Handgun.java
|
c0e1b03e163d61eb8c8b283e2b5edcb722f577f0
|
[] |
no_license
|
anzhiyi1988/MyCode
|
2800259c8a711fc0d7ae2f54b049914664db07d4
|
2d38dca4ba82a811a89be426ce08e9778d6b972b
|
refs/heads/master
| 2023-01-08T22:57:46.992941
| 2022-12-20T10:56:43
| 2022-12-20T10:56:43
| 116,620,677
| 0
| 0
| null | 2023-01-05T05:19:05
| 2018-01-08T02:45:38
|
JavaScript
|
UTF-8
|
Java
| false
| false
| 193
|
java
|
package orz.an.design.pattern.base.lsv;
/**
* @author anzhy
* @version 1.0
* @created 07-8��-2018 11:52:56
*/
public class Handgun extends AbstractGun {
public void shoot() {
}
}
|
[
"anzhiyi1988@163.com"
] |
anzhiyi1988@163.com
|
ca1474f373f0d61c22d9e075bc942b444611d9e7
|
2061f0c6f38cf95390cdadc30465382e123ac911
|
/project_salesforce/TC4EditCampaignView.java
|
d81e46f06b8c616eca8150fbbae263751fc34993
|
[] |
no_license
|
bala8290/src
|
afafb9ca4aef8bf2e9b8f8cc786026ff276fe2f9
|
ceee3e72c4fe26a802770fa16fef54fb7dfbee3b
|
refs/heads/master
| 2021-01-19T05:39:27.879959
| 2014-01-07T16:41:30
| 2014-01-07T16:41:30
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 632
|
java
|
package project_salesforce;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import jxl.read.biff.BiffException;
import jxl.write.WriteException;
public class TC4EditCampaignView {
public TC4EditCampaignView(String testcasename,String BrowserName) throws WriteException, IOException, ParserConfigurationException, TransformerException, BiffException
{
AppSpecific App = new AppSpecific(testcasename,BrowserName);
App.ReaddataforLogin(App,false);
App.EditCampaignView("DeathChest8290");
App.logoutApp();
App.finishingTouch();
}
}
|
[
"balacyno@gmail.com"
] |
balacyno@gmail.com
|
b9a528786ebdb12f438f93ddaa79cd8803ba38ce
|
4ecd637d750d155cc98b8c59ad733a2ea2969a4a
|
/apps/Mezzmo-ejb/src/be/home/mezzmo/domain/dao/jdbc/MezzmoAlbumArtistDAOImpl.java
|
156fa0f103633064af6821b1c3f7fc6fde98cc2d
|
[] |
no_license
|
ghyssee/Home
|
0a6e6a96880321b9874b15916f389a8e6ab3d726
|
e624cd6a7966d6312add25986a6ba57888b0926b
|
refs/heads/master
| 2023-08-17T02:32:06.816172
| 2023-08-12T21:05:01
| 2023-08-12T21:05:01
| 56,686,794
| 2
| 0
| null | 2023-05-23T20:15:38
| 2016-04-20T12:56:18
|
Java
|
UTF-8
|
Java
| false
| false
| 2,841
|
java
|
package be.home.mezzmo.domain.dao.jdbc;
import be.home.mezzmo.domain.model.MGOAlbumArtistTO;
import be.home.mezzmo.domain.model.MGOFileAlbumCompositeTO;
import be.home.mezzmo.domain.model.Result;
import java.util.List;
/**
* Created by Gebruiker on 12/03/2017.
*/
public class MezzmoAlbumArtistDAOImpl extends MezzmoRowMappers {
public MGOAlbumArtistTO findAlbumArtist(MGOAlbumArtistTO albumArtist){
Object[] params = {
albumArtist.getName()
};
MGOAlbumArtistTO albumArtistTO = (MGOAlbumArtistTO) getInstance().getJDBCTemplate().
queryForObject(FIND_ALBUM_ARTIST, new AlbumArtistRowMapper(), params);
return albumArtistTO;
}
public MGOAlbumArtistTO findAlbumArtistById(MGOAlbumArtistTO albumArtist){
Object[] params = {
albumArtist.getId()
};
MGOAlbumArtistTO albumArtistTO = (MGOAlbumArtistTO) getInstance().getJDBCTemplate().
queryForObject(FIND_ALBUM_ARTIST_BY_ID, new AlbumArtistRowMapper(), params);
return albumArtistTO;
}
public int updateAlbumArtist(MGOAlbumArtistTO albumArtist) {
Object params[] = {albumArtist.getName(), albumArtist.getId()};
int nr = getInstance().getJDBCTemplate().update(FILE_UPDATE_ALBUM_ARTIST, params);
return nr;
}
public int updateLinkFileAlbumArtist2(MGOFileAlbumCompositeTO comp){
Object[] params;
params = new Object[] {comp.getAlbumArtistTO().getId(), comp.getFileTO().getId()};
int nr = getInstance().getJDBCTemplate().update(UPDATE_LINK_FILE_ALBUM_ARTIST2, params);
return nr;
}
public List<MGOFileAlbumCompositeTO> findLinkedAlbumArtist(MGOAlbumArtistTO albumArtist){
Object[] params = {
albumArtist.getId()
};
List <MGOFileAlbumCompositeTO> list = getInstance().getJDBCTemplate().query(FIND_LINKED_ALBUM_ARTIST, new FileAlbumArtistRowMapper(), params);
return list;
}
public Result updateLinkFileAlbumArtist(MGOAlbumArtistTO albumArtist, Long newId){
Object[] params;
Result result = new Result();
params = new Object[] {newId, albumArtist.getId()};
result.setNr1(getInstance().getJDBCTemplate().update(UPDATE_LINK_FILE_ALBUM_ARTIST, params));
return result;
}
public int deleteAlbumArtist(MGOAlbumArtistTO albumArtist){
Object[] params;
params = new Object[] {albumArtist.getId()};
int nr = getInstance().getJDBCTemplate().update(DELETE_ALBUM_ARTIST, params);
return nr;
}
public Long insertAlbumArtist(final MGOAlbumArtistTO albumArtist){
Object[] params = {albumArtist.getName()};
Long key = insertJDBC(getInstance().getJDBCTemplate(), params, INSERT_ALBUM_ARTIST, "id");
return key;
}
}
|
[
"eric.ghyssens@hotmail.nl"
] |
eric.ghyssens@hotmail.nl
|
2873e46cbfea4f088f9edd63a716e13508c8e512
|
de752b1dab1d9ed20c44e30ffa1ff887b868d2b0
|
/base/commons/src/main/java/com/gapache/commons/jvm/classloader/MyTest10.java
|
3be0b096bba95eed976e5a60f97e8d6f67aa822b
|
[] |
no_license
|
KeKeKuKi/IACAA30
|
33fc99ba3f1343240fe3fafe82bee01339273b80
|
6f3f6091b2ca6dd92f22b1697c0fbfc7b9b7d371
|
refs/heads/main
| 2023-04-07T21:18:49.105964
| 2021-04-08T08:41:57
| 2021-04-08T08:41:57
| 352,832,814
| 3
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 946
|
java
|
package com.gapache.commons.jvm.classloader;
/**
* @author HuSen
* create on 2020/1/21 15:23
*/
public class MyTest10 {
public static void main(String[] args) throws ClassNotFoundException {
// 调用ClassLoader类的loadClass方法加载一个类,并不是对类的主动使用,不会导致初始化
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
Class<?> aClass = classLoader.loadClass("com.gapache.commons.jvm.classloader.CL");
System.out.println(aClass);
System.out.println("-------------------------");
Class<?> aClass1 = Class.forName("com.gapache.commons.jvm.classloader.CL");
System.out.println(aClass1);
// class com.gapache.commons.jvm.classloader.CL
// -------------------------
// Class CL
// class com.gapache.commons.jvm.classloader.CL
}
}
class CL {
static {
System.out.println("Class CL");
}
}
|
[
"2669918628@qq.com"
] |
2669918628@qq.com
|
f0088b9b1950e22af298308388a7c9d96460af71
|
38933bae7638a11fef6836475fef0d73e14c89b5
|
/magma-func/src/main/java/eu/lunisolar/magma/func/function/to/LTieSrtFunction.java
|
c6fc38ee0a90c41139b52a16b9dbf67330a9403e
|
[
"Apache-2.0"
] |
permissive
|
lunisolar/magma
|
b50ed45ce2f52daa5c598e4760c1e662efbbc0d4
|
41d3db2491db950685fe403c934cfa71f516c7dd
|
refs/heads/master
| 2023-08-03T10:13:20.113127
| 2023-07-24T15:01:49
| 2023-07-24T15:01:49
| 29,874,142
| 5
| 0
|
Apache-2.0
| 2023-05-09T18:25:01
| 2015-01-26T18:03:44
|
Java
|
UTF-8
|
Java
| false
| false
| 33,289
|
java
|
/*
* This file is part of "lunisolar-magma".
*
* (C) Copyright 2014-2023 Lunisolar (http://lunisolar.eu/).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package eu.lunisolar.magma.func.function.to;
import javax.annotation.Nonnull; // NOSONAR
import javax.annotation.Nullable; // NOSONAR
import javax.annotation.concurrent.NotThreadSafe; // NOSONAR
import java.util.Comparator; // NOSONAR
import java.util.Objects; // NOSONAR
import eu.lunisolar.magma.basics.*; //NOSONAR
import eu.lunisolar.magma.basics.builder.*; // NOSONAR
import eu.lunisolar.magma.basics.exceptions.*; // NOSONAR
import eu.lunisolar.magma.basics.meta.*; // NOSONAR
import eu.lunisolar.magma.basics.meta.aType.*; // NOSONAR
import eu.lunisolar.magma.basics.meta.functional.*; // NOSONAR
import eu.lunisolar.magma.basics.meta.functional.type.*; // NOSONAR
import eu.lunisolar.magma.basics.meta.functional.domain.*; // NOSONAR
import eu.lunisolar.magma.func.IA;
import eu.lunisolar.magma.func.SA;
import eu.lunisolar.magma.func.*; // NOSONAR
import eu.lunisolar.magma.func.tuple.*; // NOSONAR
import java.util.concurrent.*; // NOSONAR
import java.util.function.*; // NOSONAR
import java.util.*; // NOSONAR
import java.lang.reflect.*; // NOSONAR
import java.util.stream.Stream; // NOSONAR
import eu.lunisolar.magma.func.action.*; // NOSONAR
import eu.lunisolar.magma.func.consumer.*; // NOSONAR
import eu.lunisolar.magma.func.consumer.primitives.*; // NOSONAR
import eu.lunisolar.magma.func.consumer.primitives.bi.*; // NOSONAR
import eu.lunisolar.magma.func.consumer.primitives.obj.*; // NOSONAR
import eu.lunisolar.magma.func.consumer.primitives.tri.*; // NOSONAR
import eu.lunisolar.magma.func.function.*; // NOSONAR
import eu.lunisolar.magma.func.function.conversion.*; // NOSONAR
import eu.lunisolar.magma.func.function.from.*; // NOSONAR
import eu.lunisolar.magma.func.function.to.*; // NOSONAR
import eu.lunisolar.magma.func.operator.binary.*; // NOSONAR
import eu.lunisolar.magma.func.operator.ternary.*; // NOSONAR
import eu.lunisolar.magma.func.operator.unary.*; // NOSONAR
import eu.lunisolar.magma.func.predicate.*; // NOSONAR
import eu.lunisolar.magma.func.supplier.*; // NOSONAR
/**
* Non-throwing functional interface (lambda) LTieSrtFunction for Java 8.
*
* Type: function
*
* Domain (lvl: 3): T a1,int a2,short a3
*
* Co-domain: int
*
* Special case of function that corresponds to TIE consumer with return integer value.
*
*/
@FunctionalInterface
@SuppressWarnings("UnusedDeclaration")
public interface LTieSrtFunction<T> extends MetaFunction, MetaInterface.NonThrowing, TieFunction<T, aShort>, Codomain<aInt>, Domain3<a<T>, aInt, aShort> { // NOSONAR
String DESCRIPTION = "LTieSrtFunction: int applyAsInt(T a1,int a2,short a3)";
// int applyAsInt(T a1,int a2,short a3) ;
default int applyAsInt(T a1, int a2, short a3) {
// return nestingApplyAsInt(a1,a2,a3);
try {
return this.applyAsIntX(a1, a2, a3);
} catch (Throwable e) { // NOSONAR
throw Handling.nestCheckedAndThrow(e);
}
}
/**
* Implement this, but call applyAsInt(T a1,int a2,short a3)
*/
int applyAsIntX(T a1, int a2, short a3) throws Throwable;
default int tupleApplyAsInt(LObjIntSrtTriple<T> args) {
return applyAsInt(args.first(), args.second(), args.third());
}
/** Function call that handles exceptions according to the instructions. */
default int handlingApplyAsInt(T a1, int a2, short a3, HandlingInstructions<Throwable, RuntimeException> handling) {
try {
return this.applyAsIntX(a1, a2, a3);
} catch (Throwable e) { // NOSONAR
throw Handler.handleOrNest(e, handling);
}
}
default LTieSrtFunction<T> handling(HandlingInstructions<Throwable, RuntimeException> handling) {
return (a1, a2, a3) -> handlingApplyAsInt(a1, a2, a3, handling);
}
default int applyAsInt(T a1, int a2, short a3, @Nonnull ExWMF<RuntimeException> factory, @Nonnull String newMessage) {
try {
return this.applyAsIntX(a1, a2, a3);
} catch (Throwable e) { // NOSONAR
throw Handling.wrap(e, factory, newMessage);
}
}
default int applyAsInt(T a1, int a2, short a3, @Nonnull ExWMF<RuntimeException> factory, @Nonnull String newMessage, @Nullable Object param1) {
try {
return this.applyAsIntX(a1, a2, a3);
} catch (Throwable e) { // NOSONAR
throw Handling.wrap(e, factory, newMessage, param1);
}
}
default int applyAsInt(T a1, int a2, short a3, @Nonnull ExWMF<RuntimeException> factory, @Nonnull String newMessage, @Nullable Object param1, @Nullable Object param2) {
try {
return this.applyAsIntX(a1, a2, a3);
} catch (Throwable e) { // NOSONAR
throw Handling.wrap(e, factory, newMessage, param1, param2);
}
}
default int applyAsInt(T a1, int a2, short a3, @Nonnull ExWMF<RuntimeException> factory, @Nonnull String newMessage, @Nullable Object param1, @Nullable Object param2, @Nullable Object param3) {
try {
return this.applyAsIntX(a1, a2, a3);
} catch (Throwable e) { // NOSONAR
throw Handling.wrap(e, factory, newMessage, param1, param2, param3);
}
}
default LTieSrtFunction<T> trying(@Nonnull ExWMF<RuntimeException> factory, @Nonnull String newMessage) {
return (a1, a2, a3) -> applyAsInt(a1, a2, a3, factory, newMessage);
}
default LTieSrtFunction<T> trying(@Nonnull ExWMF<RuntimeException> factory, @Nonnull String newMessage, @Nullable Object param1) {
return (a1, a2, a3) -> applyAsInt(a1, a2, a3, factory, newMessage, param1);
}
default LTieSrtFunction<T> trying(@Nonnull ExWMF<RuntimeException> factory, @Nonnull String newMessage, @Nullable Object param1, @Nullable Object param2) {
return (a1, a2, a3) -> applyAsInt(a1, a2, a3, factory, newMessage, param1, param1);
}
default LTieSrtFunction<T> trying(@Nonnull ExWMF<RuntimeException> factory, @Nonnull String newMessage, @Nullable Object param1, @Nullable Object param2, @Nullable Object param3) {
return (a1, a2, a3) -> applyAsInt(a1, a2, a3, factory, newMessage, param1, param2, param3);
}
default int applyAsInt(T a1, int a2, short a3, @Nonnull ExWF<RuntimeException> factory) {
try {
return this.applyAsIntX(a1, a2, a3);
} catch (Throwable e) { // NOSONAR
throw Handling.wrap(e, factory);
}
}
default LTieSrtFunction<T> trying(@Nonnull ExWF<RuntimeException> factory) {
return (a1, a2, a3) -> applyAsInt(a1, a2, a3, factory);
}
default int applyAsIntThen(T a1, int a2, short a3, @Nonnull LToIntFunction<Throwable> handler) {
try {
return this.applyAsIntX(a1, a2, a3);
} catch (Throwable e) { // NOSONAR
Handling.handleErrors(e);
return handler.applyAsInt(e);
}
}
default LTieSrtFunction<T> tryingThen(@Nonnull LToIntFunction<Throwable> handler) {
return (a1, a2, a3) -> applyAsIntThen(a1, a2, a3, handler);
}
/** Function call that handles exceptions by always nesting checked exceptions and propagating the others as is. */
default int nestingApplyAsInt(T a1, int a2, short a3) {
try {
return this.applyAsIntX(a1, a2, a3);
} catch (Throwable e) { // NOSONAR
throw Handling.nestCheckedAndThrow(e);
}
}
/** Function call that handles exceptions by always propagating them as is, even when they are undeclared checked ones. */
default int shovingApplyAsInt(T a1, int a2, short a3) {
try {
return this.applyAsIntX(a1, a2, a3);
} catch (Throwable e) { // NOSONAR
throw Handling.shoveIt(e);
}
}
static <T> int shovingApplyAsInt(T a1, int a2, short a3, LTieSrtFunction<T> func) {
Null.nonNullArg(func, "func");
return func.shovingApplyAsInt(a1, a2, a3);
}
static <T> int handlingApplyAsInt(T a1, int a2, short a3, LTieSrtFunction<T> func, HandlingInstructions<Throwable, RuntimeException> handling) { // <-
Null.nonNullArg(func, "func");
return func.handlingApplyAsInt(a1, a2, a3, handling);
}
static <T> int tryApplyAsInt(T a1, int a2, short a3, LTieSrtFunction<T> func) {
Null.nonNullArg(func, "func");
return func.nestingApplyAsInt(a1, a2, a3);
}
static <T> int tryApplyAsInt(T a1, int a2, short a3, LTieSrtFunction<T> func, @Nonnull ExWMF<RuntimeException> factory, @Nonnull String newMessage) {
Null.nonNullArg(func, "func");
return func.applyAsInt(a1, a2, a3, factory, newMessage);
}
static <T> int tryApplyAsInt(T a1, int a2, short a3, LTieSrtFunction<T> func, @Nonnull ExWMF<RuntimeException> factory, @Nonnull String newMessage, @Nullable Object param1) {
Null.nonNullArg(func, "func");
return func.applyAsInt(a1, a2, a3, factory, newMessage, param1);
}
static <T> int tryApplyAsInt(T a1, int a2, short a3, LTieSrtFunction<T> func, @Nonnull ExWMF<RuntimeException> factory, @Nonnull String newMessage, @Nullable Object param1, @Nullable Object param2) {
Null.nonNullArg(func, "func");
return func.applyAsInt(a1, a2, a3, factory, newMessage, param1, param2);
}
static <T> int tryApplyAsInt(T a1, int a2, short a3, LTieSrtFunction<T> func, @Nonnull ExWMF<RuntimeException> factory, @Nonnull String newMessage, @Nullable Object param1, @Nullable Object param2, @Nullable Object param3) {
Null.nonNullArg(func, "func");
return func.applyAsInt(a1, a2, a3, factory, newMessage, param1, param2, param3);
}
static <T> int tryApplyAsInt(T a1, int a2, short a3, LTieSrtFunction<T> func, @Nonnull ExWF<RuntimeException> factory) {
Null.nonNullArg(func, "func");
return func.applyAsInt(a1, a2, a3, factory);
}
static <T> int tryApplyAsIntThen(T a1, int a2, short a3, LTieSrtFunction<T> func, @Nonnull LToIntFunction<Throwable> handler) {
Null.nonNullArg(func, "func");
return func.applyAsIntThen(a1, a2, a3, handler);
}
/** Just to mirror the method: Ensures the result is not null */
default int nonNullApplyAsInt(T a1, int a2, short a3) {
return applyAsInt(a1, a2, a3);
}
/** Returns description of the functional interface. */
@Nonnull
default String functionalInterfaceDescription() {
return LTieSrtFunction.DESCRIPTION;
}
/** From-To. Intended to be used with non-capturing lambda. */
public static <T> void fromTo(int min_a2, int max_a2, T a1, short a3, @Nonnull LTieSrtFunction<T> func) {
Null.nonNullArg(func, "func");
if (min_a2 <= max_a2) {
for (int a2 = min_a2; a2 <= max_a2; a2++) {
func.applyAsInt(a1, a2, a3);
}
} else {
for (int a2 = min_a2; a2 >= max_a2; a2--) {
func.applyAsInt(a1, a2, a3);
}
}
}
/** From-To. Intended to be used with non-capturing lambda. */
public static <T> void fromTill(int min_a2, int max_a2, T a1, short a3, @Nonnull LTieSrtFunction<T> func) {
Null.nonNullArg(func, "func");
if (min_a2 <= max_a2) {
for (int a2 = min_a2; a2 < max_a2; a2++) {
func.applyAsInt(a1, a2, a3);
}
} else {
for (int a2 = min_a2; a2 > max_a2; a2--) {
func.applyAsInt(a1, a2, a3);
}
}
}
/** From-To. Intended to be used with non-capturing lambda. */
public static <T> void times(int max_a2, T a1, short a3, @Nonnull LTieSrtFunction<T> func) {
if (max_a2 < 0)
return;
fromTill(0, max_a2, a1, a3, func);
}
/** Extract and apply function. */
public static <M, K, V> int from(@Nonnull M container, LBiFunction<M, K, V> extractor, K key, int a2, short a3, @Nonnull LTieSrtFunction<V> function, int orElse) {
Null.nonNullArg(container, "container");
Null.nonNullArg(function, "function");
V value = extractor.apply(container, key);
if (value != null) {
return function.applyAsInt(value, a2, a3);
}
return orElse;
}
/** */
public static <T> LTieSrtFunction<T> uncurry(@Nonnull LFunction<T, LIntFunction<LSrtToIntFunction>> func) {
Null.nonNullArg(func, "func");
return (T a1, int a2, short a3) -> func.apply(a1).apply(a2).applyAsInt(a3);
}
/** Change function to consumer that ignores output. */
default LTieSrtConsumer<T> toConsumer() {
return this::applyAsInt;
}
/** Calls domain consumer before main function. */
default LTieSrtFunction<T> beforeDo(@Nonnull LTieSrtConsumer<T> before) {
Null.nonNullArg(before, "before");
return (T a1, int a2, short a3) -> {
before.accept(a1, a2, a3);
return applyAsInt(a1, a2, a3);
};
}
/** Calls codomain consumer after main function. */
default LTieSrtFunction<T> afterDo(@Nonnull LIntConsumer after) {
Null.nonNullArg(after, "after");
return (T a1, int a2, short a3) -> {
final int retval = applyAsInt(a1, a2, a3);
after.accept(retval);
return retval;
};
}
/** Creates function that always returns the same value. */
static <T> LTieSrtFunction<T> constant(int r) {
return (a1, a2, a3) -> r;
}
/** Convenient method in case lambda expression is ambiguous for the compiler (that might happen for overloaded methods accepting different interfaces). */
@Nonnull
static <T> LTieSrtFunction<T> tieSrtFunc(final @Nonnull LTieSrtFunction<T> lambda) {
Null.nonNullArg(lambda, "lambda");
return lambda;
}
// <editor-fold desc="recursive">
final class S<T> implements LTieSrtFunction<T> {
private LTieSrtFunction<T> target = null;
@Override
public int applyAsIntX(T a1, int a2, short a3) throws Throwable {
return target.applyAsIntX(a1, a2, a3);
}
}
@Nonnull
static <T> LTieSrtFunction<T> recursive(final @Nonnull LFunction<LTieSrtFunction<T>, LTieSrtFunction<T>> selfLambda) {
final S<T> single = new S();
LTieSrtFunction<T> func = selfLambda.apply(single);
single.target = func;
return func;
}
// </editor-fold>
// <editor-fold desc="memento">
public static <T> M<T> mementoOf(T a1, int a2, short a3, LTieSrtFunction<T> function) {
var initialValue = function.applyAsInt(a1, a2, a3);
return initializedMementoOf(initialValue, function);
}
public static <T> M<T> initializedMementoOf(int initialValue, LTieSrtFunction<T> function) {
return memento(initialValue, initialValue, function, (m, x1, x2) -> x2);
}
public static <T> M<T> deltaOf(T a1, int a2, short a3, LTieSrtFunction<T> function, LIntBinaryOperator deltaFunction) {
var initialValue = function.applyAsInt(a1, a2, a3);
return initializedDeltaOf(initialValue, function, deltaFunction);
}
public static <T> M<T> deltaOf(T a1, int a2, short a3, LTieSrtFunction<T> function) {
var initialValue = function.applyAsInt(a1, a2, a3);
return initializedDeltaOf(initialValue, function, (x1, x2) -> (x2 - x1));
}
public static <T> M<T> initializedDeltaOf(int initialValue, LTieSrtFunction<T> function, LIntBinaryOperator deltaFunction) {
return memento(initialValue, deltaFunction.applyAsInt(initialValue, initialValue), function, (m, x1, x2) -> deltaFunction.applyAsInt(x1, x2));
}
public static <T> M<T> memento(int initialBaseValue, int initialValue, LTieSrtFunction<T> baseFunction, LIntTernaryOperator mementoFunction) {
return new M(initialBaseValue, initialValue, baseFunction, mementoFunction);
}
/**
* Implementation that allows to create derivative functions (do not confuse it with math concepts). Very short name is intended to be used with parent (LTieSrtFunction.M)
*/
@NotThreadSafe
final class M<T> implements LTieSrtFunction<T> {
private final LTieSrtFunction<T> baseFunction;
private int lastBaseValue;
private int lastValue;
private final LIntTernaryOperator mementoFunction;
private M(int lastBaseValue, int lastValue, LTieSrtFunction<T> baseFunction, LIntTernaryOperator mementoFunction) {
this.baseFunction = baseFunction;
this.lastBaseValue = lastBaseValue;
this.lastValue = lastValue;
this.mementoFunction = mementoFunction;
}
@Override
public int applyAsIntX(T a1, int a2, short a3) throws Throwable {
int x1 = lastBaseValue;
int x2 = lastBaseValue = baseFunction.applyAsIntX(a1, a2, a3);
return lastValue = mementoFunction.applyAsIntX(lastValue, x1, x2);
}
public int currentApplyAsInt(T a1, int a2, short a3) {
int x1 = lastBaseValue;
int x2 = baseFunction.applyAsInt(a1, a2, a3);
return mementoFunction.applyAsInt(lastValue, x1, x2);
}
public int lastValue() {
return lastValue;
};
public int lastBaseValue() {
return lastBaseValue;
};
}
// </editor-fold>
@Nonnull
static <T> LTieSrtFunction<T> tieSrtFuncThrowing(final @Nonnull ExF<Throwable> exF) {
Null.nonNullArg(exF, "exF");
return (a1, a2, a3) -> {
throw exF.produce();
};
}
@Nonnull
static <T> LTieSrtFunction<T> tieSrtFuncThrowing(final String message, final @Nonnull ExMF<Throwable> exF) {
Null.nonNullArg(exF, "exF");
return (a1, a2, a3) -> {
throw exF.produce(message);
};
}
static <T> int call(T a1, int a2, short a3, final @Nonnull LTieSrtFunction<T> lambda) {
Null.nonNullArg(lambda, "lambda");
return lambda.applyAsInt(a1, a2, a3);
}
// <editor-fold desc="wrap">
// </editor-fold>
// <editor-fold desc="compose (functional)">
/** Allows to manipulate the domain of the function. */
@Nonnull
default <V1> LTieSrtFunction<V1> compose(@Nonnull final LFunction<? super V1, ? extends T> before1, @Nonnull final LIntUnaryOperator before2, @Nonnull final LSrtUnaryOperator before3) {
Null.nonNullArg(before1, "before1");
Null.nonNullArg(before2, "before2");
Null.nonNullArg(before3, "before3");
return (v1, v2, v3) -> this.applyAsInt(before1.apply(v1), before2.applyAsInt(v2), before3.applyAsSrt(v3));
}
/** Allows to manipulate the domain of the function. */
@Nonnull
default <V1, V2, V3> LToIntTriFunction<V1, V2, V3> unboxingCompose(@Nonnull final LFunction<? super V1, ? extends T> before1, @Nonnull final LToIntFunction<? super V2> before2, @Nonnull final LToSrtFunction<? super V3> before3) {
Null.nonNullArg(before1, "before1");
Null.nonNullArg(before2, "before2");
Null.nonNullArg(before3, "before3");
return (v1, v2, v3) -> this.applyAsInt(before1.apply(v1), before2.applyAsInt(v2), before3.applyAsSrt(v3));
}
// </editor-fold>
// <editor-fold desc="then (functional)">
/** Combines two functions together in a order. */
@Nonnull
default <V> LObjIntSrtFunction<T, V> then(@Nonnull LIntFunction<? extends V> after) {
Null.nonNullArg(after, "after");
return (a1, a2, a3) -> after.apply(this.applyAsInt(a1, a2, a3));
}
/** Combines two functions together in a order. */
@Nonnull
default LTieSrtFunction<T> thenToInt(@Nonnull LIntUnaryOperator after) {
Null.nonNullArg(after, "after");
return (a1, a2, a3) -> after.applyAsInt(this.applyAsInt(a1, a2, a3));
}
/** Combines two functions together in a order. */
@Nonnull
default LObjIntSrtPredicate<T> thenToBool(@Nonnull LIntPredicate after) {
Null.nonNullArg(after, "after");
return (a1, a2, a3) -> after.test(this.applyAsInt(a1, a2, a3));
}
// </editor-fold>
// <editor-fold desc="variant conversions">
// </editor-fold>
/** Does nothing (LTieSrtFunction) Function */
public static <T> int doNothing(T a1, int a2, short a3) {
return Function4U.defaultInteger;
}
/** ***ITERATION: TIE_CONSUMER_GEN: FOR, [SourcePurpose{arg=int sStart, type=CONST}, SourcePurpose{arg=int sEnd, type=CONST}, SourcePurpose{arg=int tStart, type=CONST}, SourcePurpose{arg=T trg1, type=CONST}, SourcePurpose{arg=short a3, type=TIE_SOURCE}, SourcePurpose{arg=short a3, type=TIE_GEN_SUPPLIER}] */
default <SRC> int genericTieForEach(int sStart, int sEnd, int tStart, T trg1, SRC src3, OiFunction<SRC, aShort> srcAcc3) {
return tieForEach(sStart, sEnd, tStart, trg1, src3, (LOiToSrtFunction<SRC>) srcAcc3, this);
}
/** ***ITERATION: TARGETED_INDEXED_FOR_EACH: FOR, [SourcePurpose{arg=T trg1, type=CONST}, SourcePurpose{arg=short a3, type=IA}, SourcePurpose{arg=LTieSrtFunction<? super T> consumer, type=CONST}] */
public static <T, C3> T tiForEach(T trg1, IndexedRead<C3, aShort> ia3, C3 source3, LTieSrtFunction<? super T> consumer) {
tieForEach(trg1, ia3, source3, consumer);
return trg1;
}
/** ***ITERATION: TARGETED_INDEXED_FOR_EACH_NEW: FOR, [SourcePurpose{arg=T trg1, type=SIZE_FACTORY}, SourcePurpose{arg=short a3, type=IA}, SourcePurpose{arg=LTieSrtFunction<? super T> consumer, type=CONST}] */
public static <T, C3> T ntiForEach(LIntFunction<T> trgFactory1, IndexedRead<C3, aShort> ia3, C3 source3, LTieSrtFunction<? super T> consumer) {
int size = ia3.size(source3);
T trg1 = trgFactory1.apply(size);
tieForEach(0, size, 0, trg1, source3, ia3.getter(), consumer);
return trg1;
}
/** ***ITERATION: TIE_CONSUMER_SHORT: FOR, [SourcePurpose{arg=T trg1, type=CONST}, SourcePurpose{arg=short a3, type=IA}, SourcePurpose{arg=LTieSrtFunction<? super T> consumer, type=CONST}] */
public static <T, C3> int tieForEach(T trg1, IndexedRead<C3, aShort> ia3, C3 source3, LTieSrtFunction<? super T> consumer) {
int size = ia3.size(source3);
return tieForEach(0, size, 0, trg1, source3, ia3.getter(), consumer);
}
/** ***ITERATION: TIE_CONSUMER: FOR, [SourcePurpose{arg=int sStart, type=CONST}, SourcePurpose{arg=int sEnd, type=CONST}, SourcePurpose{arg=int tStart, type=CONST}, SourcePurpose{arg=T trg1, type=CONST}, SourcePurpose{arg=short a3, type=TIE_SOURCE}, SourcePurpose{arg=short a3, type=TIE_SUPPLIER}, SourcePurpose{arg=LTieSrtFunction<? super T> consumer, type=CONST}] */
public static <T, SRC> int tieForEach(int sStart, int sEnd, int tStart, T trg1, SRC src3, LOiToSrtFunction<SRC> srcAcc3, LTieSrtFunction<? super T> consumer) {
int tIndex = tStart;
for (int sIndex = sStart; sIndex < sEnd; sIndex++) {
short a3 = srcAcc3.applyAsSrt(src3, sIndex);
tIndex += consumer.applyAsInt(trg1, tIndex, a3);
}
return tIndex - tStart;
}
/** ***ITERATION: TIE_CONSUMER2_GEN: FOR, [SourcePurpose{arg=int sStart, type=CONST}, SourcePurpose{arg=int tStart, type=CONST}, SourcePurpose{arg=T trg1, type=CONST}, SourcePurpose{arg=short a3, type=TIE_SOURCE}, SourcePurpose{arg=short a3, type=TE_GEN_PREDICATE}, SourcePurpose{arg=short a3, type=TE_GEN_SUPPLIER}] */
default <SRC> int genericTieForEach(int sStart, int tStart, T trg1, SRC src3, OFunction<SRC, aBool> srcTest3, OFunction<SRC, aShort> srcAcc3) {
return tieForEach(sStart, tStart, trg1, src3, (LPredicate<SRC>) srcTest3, (LToSrtFunction<SRC>) srcAcc3, this);
}
/**
* For each element (or tuple) from arguments, calls the consumer (with TIE: 'target', index, element). First argument is designated as 'target' object.
* Thread safety, fail-fast, fail-safety of this method depends highly on the arguments.
* @returns increment count based on consumer function
*/
public static <T, SRC> int tieForEach(int sStart, int tStart, T trg1, SRC src3, LPredicate<SRC> srcTest3, LToSrtFunction<SRC> srcAcc3, LTieSrtFunction<? super T> consumer) {
int tIndex = tStart;
for (; srcTest3.test(src3); tIndex++) {
short a3 = srcAcc3.applyAsSrt(src3);
tIndex += consumer.applyAsInt(trg1, tIndex, a3);
}
return tIndex - sStart;
}
/**
* For each element (or tuple) from arguments, calls the consumer (with TIE: 'target', index, element). First argument is designated as 'target' object.
* Thread safety, fail-fast, fail-safety of this method depends highly on the arguments.
* @returns increment count based on consumer function
*/
public static <T, C3, I3> int tieIterate(T trg1, SequentialRead<C3, I3, aShort> sa3, C3 source3, LTieSrtFunction<? super T> consumer) {
LFunction<C3, I3> toIntermediate = sa3.adapter();
return tieForEach(0, 0, trg1, toIntermediate.apply(source3), sa3.tester(), sa3.supplier(), consumer);
}
/**
* For each element (or tuple) from arguments, calls the consumer (with TIE: 'target', index, element). First argument is designated as 'target' object.
* Thread safety, fail-fast, fail-safety of this method depends highly on the arguments.
* @returns 'target' object
*/
public static <T, C3, I3> T tiIterate(T trg1, SequentialRead<C3, I3, aShort> sa3, C3 source3, LTieSrtFunction<? super T> consumer) {
tieIterate(trg1, sa3, source3, consumer);
return trg1;
}
/** ***ITERATION: TARGETED_INDEXED_ITERATE_NEW: WHILE, [SourcePurpose{arg=T trg1, type=SUPPLIER}, SourcePurpose{arg=short a3, type=SA}, SourcePurpose{arg=LTieSrtFunction<? super T> consumer, type=CONST}] */
public static <T, C3, I3> T ntiIterate(LSupplier<T> source1, SequentialRead<C3, I3, aShort> sa3, C3 source3, LTieSrtFunction<? super T> consumer) {
T trg1 = source1.get();
tieIterate(trg1, sa3, source3, consumer);
return trg1;
}
/**
* For each element (or tuple) from arguments, calls the function and passes the result to consumer.
* Thread safety, fail-fast, fail-safety of this method is not expected.
*/
default <C1, C2, C3> void forEach(IndexedRead<C1, a<T>> ia1, C1 source1, IndexedRead<C2, aInt> ia2, C2 source2, IndexedRead<C3, aShort> ia3, C3 source3, LIntConsumer consumer) {
int size = ia1.size(source1);
LOiFunction<Object, T> oiFunc1 = (LOiFunction) ia1.getter();
size = Integer.min(size, ia2.size(source2));
LOiToIntFunction<Object> oiFunc2 = (LOiToIntFunction) ia2.getter();
size = Integer.min(size, ia3.size(source3));
LOiToSrtFunction<Object> oiFunc3 = (LOiToSrtFunction) ia3.getter();
int i = 0;
for (; i < size; i++) {
T a1 = oiFunc1.apply(source1, i);
int a2 = oiFunc2.applyAsInt(source2, i);
short a3 = oiFunc3.applyAsSrt(source3, i);
consumer.accept(this.applyAsInt(a1, a2, a3));
}
}
/**
* For each element (or tuple) from arguments, calls the function and passes the result to consumer.
* Thread safety, fail-fast, fail-safety of this method is not expected.
*/
default <C1, I1, C2, C3> void iterate(SequentialRead<C1, I1, a<T>> sa1, C1 source1, IndexedRead<C2, aInt> ia2, C2 source2, IndexedRead<C3, aShort> ia3, C3 source3, LIntConsumer consumer) {
Object iterator1 = ((LFunction) sa1.adapter()).apply(source1);
LPredicate<Object> testFunc1 = (LPredicate) sa1.tester();
LFunction<Object, T> nextFunc1 = (LFunction) sa1.supplier();
int size = ia2.size(source2);
LOiToIntFunction<Object> oiFunc2 = (LOiToIntFunction) ia2.getter();
size = Integer.min(size, ia3.size(source3));
LOiToSrtFunction<Object> oiFunc3 = (LOiToSrtFunction) ia3.getter();
int i = 0;
while (testFunc1.test(iterator1) && i < size) {
T a1 = nextFunc1.apply(iterator1);
int a2 = oiFunc2.applyAsInt(source2, i);
short a3 = oiFunc3.applyAsSrt(source3, i);
consumer.accept(this.applyAsInt(a1, a2, a3));
i++;
}
}
/**
* For each element (or tuple) from arguments, calls the function and passes the result to consumer.
* Thread safety, fail-fast, fail-safety of this method is not expected.
*/
default <C1, C2, I2, C3> void iterate(IndexedRead<C1, a<T>> ia1, C1 source1, SequentialRead<C2, I2, aInt> sa2, C2 source2, IndexedRead<C3, aShort> ia3, C3 source3, LIntConsumer consumer) {
int size = ia1.size(source1);
LOiFunction<Object, T> oiFunc1 = (LOiFunction) ia1.getter();
Object iterator2 = ((LFunction) sa2.adapter()).apply(source2);
LPredicate<Object> testFunc2 = (LPredicate) sa2.tester();
LToIntFunction<Object> nextFunc2 = (LToIntFunction) sa2.supplier();
size = Integer.min(size, ia3.size(source3));
LOiToSrtFunction<Object> oiFunc3 = (LOiToSrtFunction) ia3.getter();
int i = 0;
while (i < size && testFunc2.test(iterator2)) {
T a1 = oiFunc1.apply(source1, i);
int a2 = nextFunc2.applyAsInt(iterator2);
short a3 = oiFunc3.applyAsSrt(source3, i);
consumer.accept(this.applyAsInt(a1, a2, a3));
i++;
}
}
/**
* For each element (or tuple) from arguments, calls the function and passes the result to consumer.
* Thread safety, fail-fast, fail-safety of this method is not expected.
*/
default <C1, I1, C2, I2, C3> void iterate(SequentialRead<C1, I1, a<T>> sa1, C1 source1, SequentialRead<C2, I2, aInt> sa2, C2 source2, IndexedRead<C3, aShort> ia3, C3 source3, LIntConsumer consumer) {
Object iterator1 = ((LFunction) sa1.adapter()).apply(source1);
LPredicate<Object> testFunc1 = (LPredicate) sa1.tester();
LFunction<Object, T> nextFunc1 = (LFunction) sa1.supplier();
Object iterator2 = ((LFunction) sa2.adapter()).apply(source2);
LPredicate<Object> testFunc2 = (LPredicate) sa2.tester();
LToIntFunction<Object> nextFunc2 = (LToIntFunction) sa2.supplier();
int size = ia3.size(source3);
LOiToSrtFunction<Object> oiFunc3 = (LOiToSrtFunction) ia3.getter();
int i = 0;
while (testFunc1.test(iterator1) && testFunc2.test(iterator2) && i < size) {
T a1 = nextFunc1.apply(iterator1);
int a2 = nextFunc2.applyAsInt(iterator2);
short a3 = oiFunc3.applyAsSrt(source3, i);
consumer.accept(this.applyAsInt(a1, a2, a3));
i++;
}
}
/**
* For each element (or tuple) from arguments, calls the function and passes the result to consumer.
* Thread safety, fail-fast, fail-safety of this method is not expected.
*/
default <C1, C2, C3, I3> void iterate(IndexedRead<C1, a<T>> ia1, C1 source1, IndexedRead<C2, aInt> ia2, C2 source2, SequentialRead<C3, I3, aShort> sa3, C3 source3, LIntConsumer consumer) {
int size = ia1.size(source1);
LOiFunction<Object, T> oiFunc1 = (LOiFunction) ia1.getter();
size = Integer.min(size, ia2.size(source2));
LOiToIntFunction<Object> oiFunc2 = (LOiToIntFunction) ia2.getter();
Object iterator3 = ((LFunction) sa3.adapter()).apply(source3);
LPredicate<Object> testFunc3 = (LPredicate) sa3.tester();
LToSrtFunction<Object> nextFunc3 = (LToSrtFunction) sa3.supplier();
int i = 0;
while (i < size && testFunc3.test(iterator3)) {
T a1 = oiFunc1.apply(source1, i);
int a2 = oiFunc2.applyAsInt(source2, i);
short a3 = nextFunc3.applyAsSrt(iterator3);
consumer.accept(this.applyAsInt(a1, a2, a3));
i++;
}
}
/**
* For each element (or tuple) from arguments, calls the function and passes the result to consumer.
* Thread safety, fail-fast, fail-safety of this method is not expected.
*/
default <C1, I1, C2, C3, I3> void iterate(SequentialRead<C1, I1, a<T>> sa1, C1 source1, IndexedRead<C2, aInt> ia2, C2 source2, SequentialRead<C3, I3, aShort> sa3, C3 source3, LIntConsumer consumer) {
Object iterator1 = ((LFunction) sa1.adapter()).apply(source1);
LPredicate<Object> testFunc1 = (LPredicate) sa1.tester();
LFunction<Object, T> nextFunc1 = (LFunction) sa1.supplier();
int size = ia2.size(source2);
LOiToIntFunction<Object> oiFunc2 = (LOiToIntFunction) ia2.getter();
Object iterator3 = ((LFunction) sa3.adapter()).apply(source3);
LPredicate<Object> testFunc3 = (LPredicate) sa3.tester();
LToSrtFunction<Object> nextFunc3 = (LToSrtFunction) sa3.supplier();
int i = 0;
while (testFunc1.test(iterator1) && i < size && testFunc3.test(iterator3)) {
T a1 = nextFunc1.apply(iterator1);
int a2 = oiFunc2.applyAsInt(source2, i);
short a3 = nextFunc3.applyAsSrt(iterator3);
consumer.accept(this.applyAsInt(a1, a2, a3));
i++;
}
}
/**
* For each element (or tuple) from arguments, calls the function and passes the result to consumer.
* Thread safety, fail-fast, fail-safety of this method is not expected.
*/
default <C1, C2, I2, C3, I3> void iterate(IndexedRead<C1, a<T>> ia1, C1 source1, SequentialRead<C2, I2, aInt> sa2, C2 source2, SequentialRead<C3, I3, aShort> sa3, C3 source3, LIntConsumer consumer) {
int size = ia1.size(source1);
LOiFunction<Object, T> oiFunc1 = (LOiFunction) ia1.getter();
Object iterator2 = ((LFunction) sa2.adapter()).apply(source2);
LPredicate<Object> testFunc2 = (LPredicate) sa2.tester();
LToIntFunction<Object> nextFunc2 = (LToIntFunction) sa2.supplier();
Object iterator3 = ((LFunction) sa3.adapter()).apply(source3);
LPredicate<Object> testFunc3 = (LPredicate) sa3.tester();
LToSrtFunction<Object> nextFunc3 = (LToSrtFunction) sa3.supplier();
int i = 0;
while (i < size && testFunc2.test(iterator2) && testFunc3.test(iterator3)) {
T a1 = oiFunc1.apply(source1, i);
int a2 = nextFunc2.applyAsInt(iterator2);
short a3 = nextFunc3.applyAsSrt(iterator3);
consumer.accept(this.applyAsInt(a1, a2, a3));
i++;
}
}
/**
* For each element (or tuple) from arguments, calls the function and passes the result to consumer.
* Thread safety, fail-fast, fail-safety of this method depends highly on the arguments.
*/
default <C1, I1, C2, I2, C3, I3> void iterate(SequentialRead<C1, I1, a<T>> sa1, C1 source1, SequentialRead<C2, I2, aInt> sa2, C2 source2, SequentialRead<C3, I3, aShort> sa3, C3 source3, LIntConsumer consumer) {
Object iterator1 = ((LFunction) sa1.adapter()).apply(source1);
LPredicate<Object> testFunc1 = (LPredicate) sa1.tester();
LFunction<Object, T> nextFunc1 = (LFunction) sa1.supplier();
Object iterator2 = ((LFunction) sa2.adapter()).apply(source2);
LPredicate<Object> testFunc2 = (LPredicate) sa2.tester();
LToIntFunction<Object> nextFunc2 = (LToIntFunction) sa2.supplier();
Object iterator3 = ((LFunction) sa3.adapter()).apply(source3);
LPredicate<Object> testFunc3 = (LPredicate) sa3.tester();
LToSrtFunction<Object> nextFunc3 = (LToSrtFunction) sa3.supplier();
while (testFunc1.test(iterator1) && testFunc2.test(iterator2) && testFunc3.test(iterator3)) {
T a1 = nextFunc1.apply(iterator1);
int a2 = nextFunc2.applyAsInt(iterator2);
short a3 = nextFunc3.applyAsSrt(iterator3);
consumer.accept(this.applyAsInt(a1, a2, a3));
}
}
}
|
[
"open@lunisolar.eu"
] |
open@lunisolar.eu
|
14f1ffd090c4f8807834b9d47fba8cfc3f537843
|
5fa2e8ac23f9a2279c76772672406aa57803a22d
|
/src/main/java/com/academy/project/demo/service/AuthService.java
|
94ee431ee71754e8d69684c7a5c93a1e2b1e0fbf
|
[] |
no_license
|
Bodia1999/main-project-java
|
4fbe64ab5b091fc17772a321a0b2b8be4a11c9fa
|
523d954a1879f01655147c92dbe7570f7836309c
|
refs/heads/master
| 2022-06-24T07:14:39.442227
| 2019-08-18T12:24:32
| 2019-08-18T12:24:32
| 200,051,119
| 0
| 0
| null | 2022-05-20T21:05:04
| 2019-08-01T12:58:27
|
Java
|
UTF-8
|
Java
| false
| false
| 4,052
|
java
|
package com.academy.project.demo.service;
import com.academy.project.demo.dto.response.JwtAuthenticationResponse;
import com.academy.project.demo.dto.request.LoginRequest;
import com.academy.project.demo.dto.request.SignUpRequest;
import com.academy.project.demo.entity.Role;
import com.academy.project.demo.entity.RoleName;
import com.academy.project.demo.entity.User;
import com.academy.project.demo.exception.AppException;
import com.academy.project.demo.exception.ConflictException;
import com.academy.project.demo.repository.RoleRepository;
import com.academy.project.demo.repository.UserRepository;
import com.academy.project.demo.security.JwtTokenProvider;
import com.academy.project.demo.security.UserPrincipal;
import com.stripe.exception.StripeException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import java.util.Collections;
@Service
@Slf4j
public class AuthService {
private AuthenticationManager authenticationManager;
private UserRepository userRepository;
private RoleRepository roleRepository;
private PasswordEncoder passwordEncoder;
private JwtTokenProvider tokenProvider;
private BrainTreeChargesService brainTreeChargesService;
@Autowired
public AuthService(AuthenticationManager authenticationManager, UserRepository userRepository, RoleRepository roleRepository, PasswordEncoder passwordEncoder, JwtTokenProvider tokenProvider, BrainTreeChargesService brainTreeChargesService) {
this.authenticationManager = authenticationManager;
this.userRepository = userRepository;
this.roleRepository = roleRepository;
this.passwordEncoder = passwordEncoder;
this.tokenProvider = tokenProvider;
this.brainTreeChargesService = brainTreeChargesService;
}
public JwtAuthenticationResponse authenticateUser(LoginRequest loginRequest) {
Authentication authentication = authenticationManager.authenticate(
new UsernamePasswordAuthenticationToken(
loginRequest.getEmail(),
loginRequest.getPassword()
)
);
SecurityContextHolder.getContext().setAuthentication(authentication);
String jwt = tokenProvider.generateToken(authentication);
UserPrincipal userPrincipal = (UserPrincipal) authentication.getPrincipal();
log.info("User with [email: {}] has logged in", userPrincipal.getEmail());
return new JwtAuthenticationResponse(jwt);
}
public Long registerUser(SignUpRequest signUpRequest) throws StripeException {
if (userRepository.existsByEmail(signUpRequest.getEmail())) {
throw new ConflictException("Email [email: " + signUpRequest.getEmail() + "] is already taken");
}
String stripeCustomerId = brainTreeChargesService
.createCustomer(signUpRequest);
User user = new User(signUpRequest.getName(),
signUpRequest.getSurname(),
signUpRequest.getEmail(),
signUpRequest.getPassword(),
signUpRequest.getPhoneNumber(),
stripeCustomerId);
user.setPassword(passwordEncoder.encode(signUpRequest.getPassword()));
Role userRole = roleRepository.findByName(RoleName.ROLE_USER)
.orElseThrow(() -> new AppException("User Role not set. Add default roles to database."));
user.setRoles(Collections.singleton(userRole));
log.info("Successfully registered user with [email: {}]", user.getEmail());
return userRepository.save(user).getId();
}
}
|
[
"92782560bodia"
] |
92782560bodia
|
ab3be3f5a4489b5020c2bd8e1f3a82f0d14a7df6
|
2544a78d47c799b2a51714515536541dd4cc8af8
|
/src/main/java/com/example/demo/model/Employee.java
|
e7f4fc213d8dc128e5e01b81e192203e16ab9e2f
|
[] |
no_license
|
SarraSakouhi/demo
|
1a2991db8b9fdb7f60b7de39a8bcc3387cffcf29
|
e1f0410673d68057e70a550889efa57bb1de31c9
|
refs/heads/main
| 2023-02-01T03:19:03.434408
| 2020-12-18T05:10:19
| 2020-12-18T05:10:19
| 322,493,283
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 1,207
|
java
|
package com.example.demo.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="employees")
public class Employee {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(name="first_name")
private String firstName;
@Column(name="last_name")
private String lastName;
@Column(name="email_id")
private long emailId;
public Employee() {
}
public Employee(String firstName, String lastName, long emailId) {
super();
this.firstName = firstName;
this.lastName = lastName;
this.emailId = emailId;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public long getEmailId() {
return emailId;
}
public void setEmailId(long emailId) {
this.emailId = emailId;
}
}
|
[
"sarrasakouhi93@gmail.com"
] |
sarrasakouhi93@gmail.com
|
0491b4dc5f8b9e6f9a6a7b125f122fd7802aff7d
|
2e75a1670e06d6762c0e673474e3dd94ca415340
|
/ponglab/act4 - bo/Pong.java
|
24d391fb9bde0bdf2b0abd9797e4e983057bfbf1
|
[] |
no_license
|
ChristinaWooden/apa-woodenc5571
|
7078793d7a179b6bd5d654d9929df7f2b67ad0e9
|
903591e82245fba7273751fe0144271942352f32
|
refs/heads/master
| 2020-04-25T18:54:47.028702
| 2019-05-13T20:17:34
| 2019-05-13T20:17:34
| 173,000,796
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 4,566
|
java
|
//(c) A+ Computer Science
//www.apluscompsci.com
//Name -
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Canvas;
import java.awt.event.ActionEvent;
import java.awt.event.KeyListener;
import java.awt.event.KeyEvent;
import static java.lang.Character.*;
import java.awt.image.BufferedImage;
import java.awt.event.ActionListener;
public class Pong extends Canvas implements KeyListener, Runnable
{
private Ball ball;
private Paddle leftPaddle;
private Paddle rightPaddle;
private boolean[] keys;
private BufferedImage back;
private Score score;
private Wall top;
private Wall bottom;
private Wall right;
private Wall left;
public Pong()
{
//set up all variables related to the game
ball = new Ball();
leftPaddle = new Paddle(30, 0, 10, 200, 6);
rightPaddle = new Paddle(500, 0, 10, 200, 6);
score = new Score();
keys = new boolean[4];
top = new Wall(0, 0, 700, 1);
bottom = new Wall(0, 700, 700, 1);
left = new Wall(0, 0, 1, 700);
right = new Wall(600, 0, 1, 700);
setBackground(Color.WHITE);
setVisible(true);
new Thread(this).start();
addKeyListener(this); //starts the key thread to log key strokes
}
public void update(Graphics window){
paint(window);
}
public void paint(Graphics window)
{
//set up the double buffering to make the game animation nice and smooth
Graphics2D twoDGraph = (Graphics2D)window;
//take a snap shop of the current screen and same it as an image
//that is the exact same width and height as the current screen
if(back==null)
back = (BufferedImage)(createImage(getWidth(),getHeight()));
//create a graphics reference to the back ground image
//we will draw all changes on the background image
Graphics graphToBack = back.createGraphics();
ball.moveAndDraw(graphToBack);
leftPaddle.draw(graphToBack);
rightPaddle.draw(graphToBack);
graphToBack.drawString(score.toString(), 200, 450);
//see if ball hits left wall or right wall
if((ball.didCollideLeft(left)))
{
ball.setXSpeed(0);
ball.setYSpeed(0);
score.rightPoint();
}
if ((ball.didCollideRight(right))){
ball.setXSpeed(0);
ball.setYSpeed(0);
score.leftPoint();
}
//see if the ball hits the top or bottom wall
if((ball.didCollideTop(top) || ball.didCollideBottom(bottom)))
{
ball.setYSpeed(-ball.getYSpeed());
}
//see if the ball hits the left paddle or right paddle
if ((ball.getX() <= leftPaddle.getX()) &&
((leftPaddle.getY() <= ball.getY()) && (ball.getY() <= leftPaddle.getY() + leftPaddle.getHeight())
))
{
ball.setXSpeed(-ball.getXSpeed());
}
if ((ball.getX() >= rightPaddle.getX()) &&
((rightPaddle.getY() <= ball.getY()) && (ball.getY() <= rightPaddle.getY() + rightPaddle.getHeight())
))
{
ball.setXSpeed(-ball.getXSpeed());
}
//see if the paddles need to be moved
ball.moveAndDraw(graphToBack);
leftPaddle.draw(window);
rightPaddle.draw(window);
if (!(ball.getX()>=10 && ball.getX()<=550))
{
ball.setXSpeed(-ball.getXSpeed());
}
if (!(ball.getY()>=10 && ball.getY()<=450))
{
ball.setYSpeed(-ball.getYSpeed());
}
if (keys[0])
{
//move left paddle up and draw it on the window
leftPaddle.moveUpAndDraw(graphToBack);
}
if (keys[1])
{
//move left paddle down and draw it on the window
leftPaddle.moveDownAndDraw(graphToBack);
}
if (keys[2])
{
rightPaddle.moveUpAndDraw(graphToBack);
}
if (keys[3])
{
rightPaddle.moveDownAndDraw(graphToBack);
}
twoDGraph.drawImage(back, null, 0, 0);
}
public void keyPressed(KeyEvent e)
{
switch(toUpperCase(e.getKeyChar()))
{
case 'W' : keys[0]=true; break;
case 'Z' : keys[1]=true; break;
case 'I' : keys[2]=true; break;
case 'M' : keys[3]=true; break;
}
}
public void keyReleased(KeyEvent e)
{
switch(toUpperCase(e.getKeyChar()))
{
case 'W' : keys[0]=false; break;
case 'Z' : keys[1]=false; break;
case 'I' : keys[2]=false; break;
case 'M' : keys[3]=false; break;
}
}
public void keyTyped(KeyEvent e){}
public void run()
{
try
{
while(true)
{
Thread.currentThread().sleep(8);
repaint();
}
}catch(Exception e)
{
}
}
}
|
[
"cmwooden@gmail.com"
] |
cmwooden@gmail.com
|
c980f1c1cc27d1e6c3208d5a4b49219aab05ffe4
|
30a3074c8b9e388e242c414d9f7241c1728f7809
|
/learn-shop-core-product/src/main/java/com/billow/product/api/GoodsSpuDetailApi.java
|
16036bf96c7a26a427918a2936cd14b8dbe42c85
|
[
"Apache-2.0"
] |
permissive
|
kangtsang/learn
|
a40157f054aa8ca6a8fd1458164e2c11623f9dcb
|
580fa6f7018f7807a5f2008efc96edd1c7a1f61b
|
refs/heads/master
| 2023-07-15T01:26:46.874098
| 2021-08-25T00:49:08
| 2021-08-25T00:49:08
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 2,606
|
java
|
package com.billow.product.api;
import com.billow.product.pojo.vo.GoodsSpuDetailVo;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.billow.product.service.GoodsSpuDetailService;
import com.billow.tools.utlis.ConvertUtils;
import com.billow.product.pojo.po.GoodsSpuDetailPo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author billow
* @since 2021-02-06
* @version v1.0
*/
@Slf4j
@Api(tags = {"GoodsSpuDetailApi"},value = "")
@RestController
@RequestMapping("/goodsSpuDetailApi")
public class GoodsSpuDetailApi {
@Autowired
private GoodsSpuDetailService goodsSpuDetailService;
@ApiOperation(value = "查询分页数据")
@PostMapping(value = "/findListByPage")
public IPage<GoodsSpuDetailPo> findListByPage(@RequestBody GoodsSpuDetailVo goodsSpuDetailVo){
return goodsSpuDetailService.findListByPage(goodsSpuDetailVo);
}
@ApiOperation(value = "根据id查询数据")
@GetMapping(value = "/findById/{id}")
public GoodsSpuDetailVo findById(@PathVariable("id") String id){
GoodsSpuDetailPo po = goodsSpuDetailService.getById(id);
return ConvertUtils.convert(po, GoodsSpuDetailVo.class);
}
@ApiOperation(value = "新增数据")
@PostMapping(value = "/add")
public GoodsSpuDetailVo add(@RequestBody GoodsSpuDetailVo goodsSpuDetailVo){
GoodsSpuDetailPo po = ConvertUtils.convert(goodsSpuDetailVo, GoodsSpuDetailPo.class);
goodsSpuDetailService.save(po);
return ConvertUtils.convert(po, GoodsSpuDetailVo.class);
}
@ApiOperation(value = "删除数据")
@DeleteMapping(value = "/delById/{id}")
public boolean delById(@PathVariable("id") String id){
return goodsSpuDetailService.removeById(id);
}
@ApiOperation(value = "更新数据")
@PutMapping(value = "/update")
public GoodsSpuDetailVo update(@RequestBody GoodsSpuDetailVo goodsSpuDetailVo){
GoodsSpuDetailPo po = ConvertUtils.convert(goodsSpuDetailVo, GoodsSpuDetailPo.class);
goodsSpuDetailService.updateById(po);
return ConvertUtils.convert(po, GoodsSpuDetailVo.class);
}
@ApiOperation("根据ID禁用数据")
@PutMapping("/prohibitById/{id}")
public boolean prohibitById(@PathVariable String id) {
return goodsSpuDetailService.prohibitById(id);
}
}
|
[
"lyongtao123@126.com"
] |
lyongtao123@126.com
|
a95075444075ed9b1e6c2fe3e421d3d5d67ce70f
|
31b98c799f9d878eeb2a5f75e6a19f7d73e69e64
|
/2021-03-09/src/interfaceOverride/InterfaceB.java
|
8bca86c08b2e57f6e35485141010e8dcd57ba111
|
[] |
no_license
|
DongGeon0908/Java
|
228e49e4c342489130d7975f025dcb3d2fb260af
|
b97cbd80f0a489a781a6c1f84a4a961a088061d1
|
refs/heads/master
| 2023-04-27T19:11:13.900318
| 2021-05-19T03:21:59
| 2021-05-19T03:21:59
| 326,665,026
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 84
|
java
|
package interfaceOverride;
public interface InterfaceB {
public void methodB();
}
|
[
"wrjssmjdhappy@gmail.com"
] |
wrjssmjdhappy@gmail.com
|
c4c5f26c032ba2563ec6a664817a653be587cfdf
|
c259291f0f50fac79664df231ec9ce31f88c7eaf
|
/Task4(Hospital)/src/ua/epamcourses/task4/web/actions/Index.java
|
20ffef2f80c8cc4e0891e783cc606b9703116b22
|
[] |
no_license
|
Fridon/EpamCoursesTasks
|
652db4c011b53d1bdb562b6b265b27324c6e6e75
|
a1a9c7fcd8933bd0b2749e60b6e82b67f33d5955
|
refs/heads/master
| 2021-01-10T22:06:07.744725
| 2014-12-02T15:46:00
| 2014-12-02T15:46:00
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 511
|
java
|
package ua.epamcourses.task4.web.actions;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import ua.epamcourses.task4.domain.User;
public class Index implements Action{
@Override
public String doAction(HttpServletRequest request,
HttpServletResponse response) {
HttpSession session = request.getSession();
User user = (User)session.getAttribute("user");
if(user == null)
return "login";
return "main";
}
}
|
[
"freeze_king@mail.ru"
] |
freeze_king@mail.ru
|
689e874fae3cf5cce2c29ea7db8ffb1803a22dfa
|
161a0857ca7e8c1e22fe0a2d6be7db3bd504eebb
|
/app/src/main/java/pdp/va/com/personalgoal/models/Status.java
|
83ab25f943215825ec138f4c93cb1aa2c798bb4e
|
[
"Apache-2.0"
] |
permissive
|
DilyanaKirilova/films_example
|
9046f10641fbf1bcf2dd27aea49b51af36d256ec
|
301e7c94681bfef87e147032200c59665c066ec6
|
refs/heads/master
| 2020-04-13T19:51:19.472762
| 2018-11-28T18:18:43
| 2018-11-28T18:18:43
| null | 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 165
|
java
|
package pdp.va.com.personalgoal.models;
/**
* Possible status types of a response provided to the UI
*/
public enum Status {
LOADING,
SUCCESS,
ERROR
}
|
[
"gatanasova@virtual-affairs.com"
] |
gatanasova@virtual-affairs.com
|
52ffd3e026c7923eea23ba3d9b84b49da0ea7b6e
|
5704f89e332e61a29e1c3720db761e53e436fac6
|
/spring-action-expend/src/main/java/spring/action/expend/Consumer.java
|
c97e170bf37d6100964e352be1194fab915d5600
|
[] |
no_license
|
StringBuilderSun/spring-action
|
341bb547587b57a0286555324c28dbefde9933c4
|
1e5a5adde85161129aa879aff71ff011711eb2d0
|
refs/heads/test
| 2022-07-24T21:13:21.097228
| 2019-07-08T03:22:20
| 2019-07-08T03:22:20
| 143,872,928
| 0
| 0
| null | 2022-07-08T19:16:33
| 2018-08-07T12:53:09
|
Java
|
UTF-8
|
Java
| false
| false
| 445
|
java
|
package spring.action.expend;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.List;
/**
* Created by lijinpeng on 2019/5/25.
*/
@Setter
@Getter
@Service
@ToString
public class Consumer {
private List<String> adress;
@PostConstruct
public void init()
{
System.out.println(adress);
}
}
|
[
"957143335@qq.com"
] |
957143335@qq.com
|
0e840ab92714711101343e5e4eb489b2baaa4ca0
|
36523366ad993a78c9fb067583a15812f2d8904b
|
/Chapter 7. Methods/HelloWorld5.java
|
16932fd050a9c5fc95b2086b1a68c43e18e3458d
|
[] |
no_license
|
alrha486/javaSE
|
6fd1afca8dfe75233ba6aab724db6da2decb42f8
|
6c70f5207eb950e08c44a45977b0d282cdcc6fe7
|
refs/heads/master
| 2020-03-27T12:42:00.823691
| 2018-08-29T07:37:52
| 2018-08-29T07:37:52
| 146,562,945
| 0
| 0
| null | null | null | null |
UTF-8
|
Java
| false
| false
| 174
|
java
|
public class HelloWorld5{
static String msg = "Hello, World"; //class variable, static variable
public static void main(String[] args) {
System.out.println(msg);
}
}
|
[
"alrha486@naver.com"
] |
alrha486@naver.com
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.