code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static <T> T instantiateClass(final Class<T> clazz, final Class<?>[] parameterTypes,
final Object[] parameterValues) throws BeanInstantiationException {
if (clazz.isInterface()) {
throw new BeanInstantiationException(clazz, CLASS_IS_INTERFACE);
}
try {
Constructor<T> constructor = cl... | java |
public static boolean isDataObject(final Object object) {
if (object == null) {
return true;
}
Class<?> clazz = object.getClass();
return isDataClass(clazz);
} | java |
public static boolean isDataClass(final Class<?> clazz) {
if (clazz == null || clazz.isPrimitive()) {
return true;
}
boolean isWrapperClass = contains(WRAPPER_CLASSES, clazz);
if (isWrapperClass) {
return true;
}
boolean isDataClass = contains(DATA_PRIMITIVE_CLASS, clazz);
if (i... | java |
public static String stringFor(int m)
{
switch (m)
{
case CUFFT_R2C : return "CUFFT_R2C";
case CUFFT_C2R : return "CUFFT_C2R";
case CUFFT_C2C : return "CUFFT_C2C";
case CUFFT_D2Z : return "CUFFT_D2Z";
case CUFFT_Z2D : return "CUFFT_... | java |
@Override
public void setContract(Contract c) {
super.setContract(c);
for (Field f : fields.values()) {
f.setContract(c);
}
} | java |
public Map<String,Field> getFieldsPlusParents() {
Map<String,Field> tmp = new HashMap<String,Field>();
tmp.putAll(fields);
if (extend != null && !extend.equals("")) {
Struct parent = contract.getStructs().get(extend);
tmp.putAll(parent.getFieldsPlusParents());
}
... | java |
public List<String> getFieldNamesPlusParents() {
List<String> tmp = new ArrayList<String>();
tmp.addAll(getFieldNames());
if (extend != null && !extend.equals("")) {
Struct parent = contract.getStructs().get(extend);
tmp.addAll(parent.getFieldNamesPlusParents());
... | java |
public void add(Collection<MobileApplication> mobileApplications)
{
for(MobileApplication mobileApplication : mobileApplications)
this.mobileApplications.put(mobileApplication.getId(), mobileApplication);
} | java |
private FileSystem getFileSystemSafe() throws IOException
{
try {
fs.getFileStatus(new Path("/"));
return fs;
}
catch (NullPointerException e) {
throw new IOException("file system not initialized");
}
} | java |
@Nonnull
public ETriState isValidPostalCode (@Nullable final Locale aCountry, @Nullable final String sPostalCode)
{
final IPostalCodeCountry aPostalCountry = getPostalCountryOfCountry (aCountry);
if (aPostalCountry == null)
return ETriState.UNDEFINED;
return ETriState.valueOf (aPostalCountry.isVal... | java |
public boolean isValidPostalCodeDefaultYes (@Nullable final Locale aCountry, @Nullable final String sPostalCode)
{
return isValidPostalCode (aCountry, sPostalCode).getAsBooleanValue (true);
} | java |
public boolean isValidPostalCodeDefaultNo (@Nullable final Locale aCountry, @Nullable final String sPostalCode)
{
return isValidPostalCode (aCountry, sPostalCode).getAsBooleanValue (false);
} | java |
@Nullable
@ReturnsMutableCopy
public ICommonsList <String> getPostalCodeExamples (@Nullable final Locale aCountry)
{
final IPostalCodeCountry aPostalCountry = getPostalCountryOfCountry (aCountry);
return aPostalCountry == null ? null : aPostalCountry.getAllExamples ();
} | java |
@Override
public ServiceRegistration<?> registerService(String clazz, Object service, Dictionary<String, ?> properties) {
MockServiceReference<Object> serviceReference = new MockServiceReference<Object>(getBundle(), properties);
if (serviceRegistrations.get(clazz) == null) { serviceRegistrations.put... | java |
@Override
public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException {
if (null == filteredServiceListeners.get(filter)) {
filteredServiceListeners.put(filter, new ArrayList<ServiceListener>(1));
}
filteredServiceListeners.get(filter).a... | java |
@Override
public void removeServiceListener(ServiceListener listener) {
// Note: if unfiltered service listeners are implemented
// This method needs to look for, and remove, the listener there
// as well
// Go through all of the filters, and for each filter
// remove the li... | java |
@Nonnull
public String[] getLoggerList() {
try {
Enumeration<Logger> currentLoggers = LogManager.getLoggerRepository().getCurrentLoggers();
List<String> loggerNames = new ArrayList<String>();
while (currentLoggers.hasMoreElements()) {
loggerNames.add(curre... | java |
private void checkHead(Token token, Optional<Integer> optHead) {
if (optHead.isPresent()) {
int head = optHead.get();
Preconditions.checkArgument(head >= 0 && head <= tokens.size(), String.format("Head should refer to token or 0: %s", token));
}
} | java |
public static Long getValue(final Long value, final Long defaultValue) {
return value == null ? defaultValue : value;
} | java |
public boolean read() throws IOException
{
valid = false;
File file = new File(filename);
FileReader reader = new FileReader(file);
if(file.exists())
{
// Load the file contents
contents = getContents(reader, "\n");
if(contents != null)
... | java |
public boolean read(InputStream stream) throws IOException
{
valid = false;
InputStreamReader reader = new InputStreamReader(stream);
// Load the file contents
contents = getContents(reader, "\n");
if(contents != null)
valid = true;
else
logge... | java |
private String getContents(Reader reader, String terminator) throws IOException
{
String line = null;
StringBuffer buff = new StringBuffer();
BufferedReader in = new BufferedReader(reader);
while((line = in.readLine()) != null)
{
buff.append(line);
if(... | java |
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
s.defaultReadObject();
type = null;
types = null;
} | java |
public void generatePdf(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
try {
Document document = new Document();
PdfWriter.getInstance(document, out);
if (columns == null)
{
if (rows.size() > 0) return;
... | java |
public void generateCsv(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
ICsvMapWriter csvWriter = null;
try {
csvWriter = new CsvMapWriter(new OutputStreamWriter(out), CsvPreference.STANDARD_PREFERENCE);
// the header elements are used to map the bean... | java |
public void generateXls(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
try {
Workbook wb = new HSSFWorkbook(); // or new XSSFWorkbook();
String safeName = WorkbookUtil.createSafeSheetName("Report"); // returns " O'Brien's sales "
Sheet reportS... | java |
private void readPackageListFromFile(String path, DocFile pkgListPath)
throws Fault {
DocFile file = pkgListPath.resolve(DocPaths.PACKAGE_LIST);
if (! (file.isAbsolute() || linkoffline)){
file = file.resolveAgainst(DocumentationTool.Location.DOCUMENTATION_OUTPUT);
}
... | java |
private void sort(List<ClassDoc> list) {
List<ClassDoc> classes = new ArrayList<ClassDoc>();
List<ClassDoc> interfaces = new ArrayList<ClassDoc>();
for (int i = 0; i < list.size(); i++) {
ClassDoc cd = list.get(i);
if (cd.isClass()) {
classes.add(cd);
... | java |
public static <T> T runCallableWithCpuCores(Callable<T> task, int cpuCores)
throws ExecutionException, InterruptedException
{
ForkJoinPool forkJoinPool = new ForkJoinPool(cpuCores);
return forkJoinPool.submit(task).get();
} | java |
public static <T> T runAsyncSupplierWithCpuCores(Supplier<T> supplier, int cpuCores)
throws ExecutionException, InterruptedException
{
ForkJoinPool forkJoinPool = new ForkJoinPool(cpuCores);
CompletableFuture<T> future = CompletableFuture.supplyAsync(supplier, forkJoinPool);
return future.get();
} | java |
public static Thread[] resolveRunningThreads()
{
final Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
final Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);
return threadArray;
} | java |
public final Trace alert(Class<?> c, String message) {
return _trace.alert(c, message);
} | java |
public Iterable<DFactory> queryByBaseUrl(java.lang.String baseUrl) {
return queryByField(null, DFactoryMapper.Field.BASEURL.getFieldName(), baseUrl);
} | java |
public Iterable<DFactory> queryByClientId(java.lang.String clientId) {
return queryByField(null, DFactoryMapper.Field.CLIENTID.getFieldName(), clientId);
} | java |
public Iterable<DFactory> queryByClientSecret(java.lang.String clientSecret) {
return queryByField(null, DFactoryMapper.Field.CLIENTSECRET.getFieldName(), clientSecret);
} | java |
private Sentence constructSentence(List<Token> tokens) throws IOException {
Sentence sentence;
try {
sentence = new SimpleSentence(tokens, strict);
} catch (IllegalArgumentException e) {
throw new IOException(e.getMessage());
}
return sentence;
} | java |
public boolean checkAccess(AccessFlags flags){
boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC);
boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED);
boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE);
boolean isPackage = !(isPublic || isProtected || isPrivate);
if ... | java |
public static boolean matchProduces(InternalRoute route, InternalRequest<?> request) {
if (nonEmpty(request.getAccept())) {
List<MediaType> matchedAcceptTypes = getAcceptedMediaTypes(route.getProduces(), request.getAccept());
if (nonEmpty(matchedAcceptTypes)) {
request.s... | java |
public static boolean matchConsumes(InternalRoute route, InternalRequest<?> request) {
if (route.getConsumes().contains(WILDCARD)) {
return true;
}
return route.getConsumes().contains(request.getContentType());
} | java |
public static byte[] getBytes(final InputStream sourceInputStream) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[BUFFER_SIZE];
for (int len = 0; (len = sourceInputStream.read(buffer)) != -1;) {
byteArrayOutputStream.write(buff... | java |
public static boolean write(final InputStream sourceInputStream,
final OutputStream destinationOutputStream) throws IOException {
byte[] buffer = buildBuffer(BUFFER_SIZE);
for (int len = 0; (len = sourceInputStream.read(buffer)) != -1;) {
destinationOutputStream.write(buffer, 0, len);
}
desti... | java |
public static boolean write(final byte[] sourceBytes, final OutputStream destinationOutputStream)
throws IOException {
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(destinationOutputStream);
bufferedOutputStream.write(sourceBytes, 0, sourceBytes.length);
bufferedOutputStream.flus... | java |
public <T extends DataObject> List<T> asList(Class<T> type) throws InstantiationException, IllegalAccessException {
Map<String, Field> fields = new HashMap<String, Field>();
for (String column: columns) try { fields.put(column, Beans.getKnownField(type, column)); } catch (Exception x) {}
List<T... | java |
public CachedResultSet rename(String... names) {
for (int i = 0; i < names.length; ++i) {
this.columns[i] = names[i];
}
return this;
} | java |
public Map<String, Integer> buildIndex() {
Map<String, Integer> index = new HashMap<String, Integer>();
for (int i = 0; i < columns.length; ++i) {
index.put(columns[i], i);
}
return index;
} | java |
@Programmatic
public Paperclip attach(
final DocumentAbstract documentAbstract,
final String roleName,
final Object attachTo) {
Paperclip paperclip = findByDocumentAndAttachedToAndRoleName(
documentAbstract, attachTo, roleName);
if(paperclip != nu... | java |
private void scanFraction(int pos) {
skipIllegalUnderscores();
if ('0' <= reader.ch && reader.ch <= '9') {
scanDigits(pos, 10);
}
int sp1 = reader.sp;
if (reader.ch == 'e' || reader.ch == 'E') {
reader.putChar(true);
skipIllegalUnderscores();
... | java |
private boolean isMagicComment() {
assert reader.ch == '@';
int parens = 0;
boolean stringLit = false;
int lbp = reader.bp;
char lch = reader.buf[++lbp];
if (!Character.isJavaIdentifierStart(lch)) {
// The first thing after the @ has to be the annotation iden... | java |
protected Tokens.Comment processComment(int pos, int endPos, CommentStyle style) {
if (scannerDebug)
System.out.println("processComment(" + pos
+ "," + endPos + "," + style + ")=|"
+ new String(reader.getRawCharacters(pos, endPos))
... | java |
public boolean isZeroVATAllowed (@Nonnull final Locale aCountry, final boolean bUndefinedValue)
{
ValueEnforcer.notNull (aCountry, "Country");
// first get locale specific VAT types
final VATCountryData aVATCountryData = getVATCountryData (aCountry);
return aVATCountryData != null ? aVATCountryData.i... | java |
@Nullable
public VATCountryData getVATCountryData (@Nonnull final Locale aLocale)
{
ValueEnforcer.notNull (aLocale, "Locale");
final Locale aCountry = CountryCache.getInstance ().getCountry (aLocale);
return m_aVATItemsPerCountry.get (aCountry);
} | java |
@Nullable
public IVATItem findVATItem (@Nullable final EVATItemType eType, @Nullable final BigDecimal aPercentage)
{
if (eType == null || aPercentage == null)
return null;
return findFirst (x -> x.getType ().equals (eType) && x.hasPercentage (aPercentage));
} | java |
@Nullable
public IVATItem findFirst (@Nonnull final Predicate <? super IVATItem> aFilter)
{
return CollectionHelper.findFirst (m_aAllVATItems.values (), aFilter);
} | java |
@Nonnull
@ReturnsMutableCopy
public ICommonsList <IVATItem> findAll (@Nonnull final Predicate <? super IVATItem> aFilter)
{
final ICommonsList <IVATItem> ret = new CommonsArrayList <> ();
CollectionHelper.findAll (m_aAllVATItems.values (), aFilter, ret::add);
return ret;
} | java |
static private String serialize(Throwable ex, int depth, int level)
{
StringBuffer buff = new StringBuffer();
String str = ex.toString();
// Split the first line if it's too long
int pos = str.indexOf(":");
if(str.length() < 80 || pos == -1)
{
buff.append... | java |
public static String serialize(Object[] objs)
{
StringBuffer buff = new StringBuffer();
for(int i = 0; i < objs.length; i++)
{
if(objs[i] != null)
{
buff.append(objs[i].toString());
if(i != objs.length-1)
buff.append... | java |
public static String encode(String str)
{
String ret = str;
try
{
// Obfuscate the string
if(ret != null)
ret = new String(Base64.encodeBase64(ret.getBytes()));
}
catch(NoClassDefFoundError e)
{
System.out.println("... | java |
public static String encodeBytes(byte[] bytes)
{
String ret = null;
try
{
// Obfuscate the string
if(bytes != null)
ret = new String(Base64.encodeBase64(bytes));
}
catch(NoClassDefFoundError e)
{
ret = new String(by... | java |
public static String decode(String str)
{
String ret = str;
try
{
// De-obfuscate the string
if(ret != null)
ret = new String(Base64.decodeBase64(ret.getBytes()));
}
catch(NoClassDefFoundError e)
{
System.out.printl... | java |
public static byte[] decodeBytes(String str)
{
byte[] ret = null;
try
{
// De-obfuscate the string
if(str != null)
ret = Base64.decodeBase64(str.getBytes());
}
catch(NoClassDefFoundError e)
{
ret = str.getBytes();
... | java |
public static String truncate(String str, int count)
{
if(count < 0 || str.length() <= count)
return str;
int pos = count;
for(int i = count; i >= 0 && !Character.isWhitespace(str.charAt(i)); i--, pos--);
return str.substring(0, pos)+"...";
} | java |
public static int getOccurenceCount(char c, String s)
{
int ret = 0;
for(int i = 0; i < s.length(); i++)
{
if(s.charAt(i) == c)
++ret;
}
return ret;
} | java |
public static int getOccurrenceCount(String expr, String str)
{
int ret = 0;
Pattern p = Pattern.compile(expr);
Matcher m = p.matcher(str);
while(m.find())
++ret;
return ret;
} | java |
public static boolean endsWith(StringBuffer buffer, String suffix)
{
if (suffix.length() > buffer.length())
return false;
int endIndex = suffix.length() - 1;
int bufferIndex = buffer.length() - 1;
while (endIndex >= 0)
{
if (buffer.charAt(bufferIndex)... | java |
public static String toReadableForm(String str)
{
String ret = str;
if(str != null && str.length() > 0
&& str.indexOf("\n") != -1
&& str.indexOf("\r") == -1)
{
str.replaceAll("\n", "\r\n");
}
return ret;
} | java |
public static String urlEncode(String str)
{
String ret = str;
try
{
ret = URLEncoder.encode(str, "UTF-8");
}
catch (UnsupportedEncodingException e)
{
logger.severe("Failed to encode value: "+str);
}
return ret;
} | java |
public static String stripSpaces(String s)
{
StringBuffer buff = new StringBuffer();
for(int i = 0; i < s.length(); i++)
{
char c = s.charAt(i);
if(c != ' ')
buff.append(c);
}
return buff.toString();
} | java |
public static String removeControlCharacters(String s, boolean removeCR)
{
String ret = s;
if(ret != null)
{
ret = ret.replaceAll("_x000D_","");
if(removeCR)
ret = ret.replaceAll("\r","");
}
return ret;
} | java |
public static void printCharacters(String s)
{
if(s != null)
{
logger.info("string length="+s.length());
for(int i = 0; i < s.length(); i++)
{
char c = s.charAt(i);
logger.info("char["+i+"]="+c+" ("+(int)c+")");
}
... | java |
public static String stripDoubleQuotes(String s)
{
String ret = s;
if(hasDoubleQuotes(s))
ret = s.substring(1, s.length()-1);
return ret;
} | java |
public static String stripClassNames(String str)
{
String ret = str;
if(ret != null)
{
while(ret.startsWith("java.security.PrivilegedActionException:")
|| ret.startsWith("com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl:")
|| ret.startsWith("j... | java |
public static String stripDomain(String hostname)
{
String ret = hostname;
int pos = hostname.indexOf(".");
if(pos != -1)
ret = hostname.substring(0,pos);
return ret;
} | java |
public Class<?> findClass(String className, String versionRange)
{
//if (ClassServiceBootstrap.repositoryAdmin == null)
// return null;
Class<?> c = this.getClassFromBundle(null, className, versionRange);
if (c == null) {
Object resource = this.deployThisResource(Cla... | java |
public URL findResourceURL(String resourcePath, String versionRange)
{
//if (ClassServiceBootstrap.repositoryAdmin == null)
// return null;
URL url = this.getResourceFromBundle(null, resourcePath, versionRange);
if (url == null) {
Object resource = this.deployThisRes... | java |
public ResourceBundle findResourceBundle(String resourcePath, Locale locale, String versionRange)
{
//if (ClassServiceBootstrap.repositoryAdmin == null)
// return null;
ResourceBundle resourceBundle = this.getResourceBundleFromBundle(null, resourcePath, locale, versionRange);
if... | java |
public boolean shutdownService(String serviceClass, Object service)
{
if (service == null)
return false;
if (bundleContext == null)
return false;
String filter = null;
if (serviceClass == null)
if (!(service instanceof String))
serv... | java |
public void startBundle(Bundle bundle)
{
if (bundle != null)
if ((bundle.getState() != Bundle.ACTIVE) && (bundle.getState() != Bundle.STARTING))
{
try {
bundle.start();
} catch (BundleException e) {
e.printStackTrace();
... | java |
@SuppressWarnings("unchecked")
@Override
public Dictionary<String, String> getProperties(String servicePid)
{
Dictionary<String, String> properties = null;
try {
if (servicePid != null)
{
ServiceReference caRef = bundleContext.getServiceReference(C... | java |
@Override
public boolean saveProperties(String servicePid, Dictionary<String, String> properties)
{
try {
if (servicePid != null)
{
ServiceReference caRef = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
if (caRef != ... | java |
public static byte[] read(InputStream in, boolean closeAfterwards) throws IOException {
byte[] buffer = new byte[32*1024];
ByteArrayOutputStream bas = new ByteArrayOutputStream();
for (int length; (length = in.read(buffer, 0, buffer.length)) > -1; bas.write(buffer, 0, length));
if (close... | java |
public void add(Collection<AlertPolicy> policies)
{
for(AlertPolicy policy : policies)
this.policies.put(policy.getId(), policy);
} | java |
public AlertChannelCache alertChannels(long policyId)
{
AlertChannelCache cache = channels.get(policyId);
if(cache == null)
channels.put(policyId, cache = new AlertChannelCache(policyId));
return cache;
} | java |
public void setAlertChannels(Collection<AlertChannel> channels)
{
for(AlertChannel channel : channels)
{
// Add the channel to any policies it is associated with
List<Long> policyIds = channel.getLinks().getPolicyIds();
for(long policyId : policyIds)
{... | java |
public AlertConditionCache alertConditions(long policyId)
{
AlertConditionCache cache = conditions.get(policyId);
if(cache == null)
conditions.put(policyId, cache = new AlertConditionCache(policyId));
return cache;
} | java |
public NrqlAlertConditionCache nrqlAlertConditions(long policyId)
{
NrqlAlertConditionCache cache = nrqlConditions.get(policyId);
if(cache == null)
nrqlConditions.put(policyId, cache = new NrqlAlertConditionCache(policyId));
return cache;
} | java |
public ExternalServiceAlertConditionCache externalServiceAlertConditions(long policyId)
{
ExternalServiceAlertConditionCache cache = externalServiceConditions.get(policyId);
if(cache == null)
externalServiceConditions.put(policyId, cache = new ExternalServiceAlertConditionCache(policyId)... | java |
public SyntheticsAlertConditionCache syntheticsAlertConditions(long policyId)
{
SyntheticsAlertConditionCache cache = syntheticsConditions.get(policyId);
if(cache == null)
syntheticsConditions.put(policyId, cache = new SyntheticsAlertConditionCache(policyId));
return cache;
} | java |
public PluginsAlertConditionCache pluginsAlertConditions(long policyId)
{
PluginsAlertConditionCache cache = pluginsConditions.get(policyId);
if(cache == null)
pluginsConditions.put(policyId, cache = new PluginsAlertConditionCache(policyId));
return cache;
} | java |
public InfraAlertConditionCache infraAlertConditions(long policyId)
{
InfraAlertConditionCache cache = infraConditions.get(policyId);
if(cache == null)
infraConditions.put(policyId, cache = new InfraAlertConditionCache(policyId));
return cache;
} | java |
static PrintWriter defaultWriter(Context context) {
PrintWriter result = context.get(outKey);
if (result == null)
context.put(outKey, result = new PrintWriter(System.err));
return result;
} | java |
public void initRound(Log other) {
this.noticeWriter = other.noticeWriter;
this.warnWriter = other.warnWriter;
this.errWriter = other.errWriter;
this.sourceMap = other.sourceMap;
this.recorded = other.recorded;
this.nerrors = other.nerrors;
this.nwarnings = other.... | java |
public void setVisibleSources(Map<String,Source> vs) {
visibleSrcs = new HashSet<URI>();
for (String s : vs.keySet()) {
Source src = vs.get(s);
visibleSrcs.add(src.file().toURI());
}
} | java |
public void save() throws IOException {
if (!needsSaving) return;
try (FileWriter out = new FileWriter(javacStateFilename)) {
StringBuilder b = new StringBuilder();
long millisNow = System.currentTimeMillis();
Date d = new Date(millisNow);
SimpleDateFormat... | java |
public boolean performJavaCompilations(File binDir,
String serverSettings,
String[] args,
Set<String> recentlyCompiled,
boolean[] rcValue) {
... | java |
private void addFileToTransform(Map<Transformer,Map<String,Set<URI>>> gs, Transformer t, Source s) {
Map<String,Set<URI>> fs = gs.get(t);
if (fs == null) {
fs = new HashMap<String,Set<URI>>();
gs.put(t, fs);
}
Set<URI> ss = fs.get(s.pkg().name());
if (ss =... | java |
private void buildDeprecatedAPIInfo(Configuration configuration) {
PackageDoc[] packages = configuration.packages;
PackageDoc pkg;
for (int c = 0; c < packages.length; c++) {
pkg = packages[c];
if (Util.isDeprecated(pkg)) {
getList(PACKAGE).add(pkg);
... | java |
public Object parse(String text) throws DataValidationException {
try {
preValidate(text);
Object object = _valueOf.invoke(text);
postValidate(object);
return object;
} catch (DataValidationException x) {
throw x;
} catch (Illeg... | java |
public void preValidate(String text) throws DataValidationException {
// size
Trace.g.std.note(Validator.class, "preValidate: size = " + _size);
if (_size > 0 && text.length() > _size) {
throw new DataValidationException("SIZE", _name, text);
}
// pattern
... | java |
@SuppressWarnings("unchecked")
public void postValidate(Object object) throws DataValidationException {
if (_values != null || _ranges != null) {
if (_values != null) for (Object value: _values) {
if (value.equals(object)) return;
}
if (_ranges != ... | java |
public void startRobot(Robot newRobot) {
newRobot.getData().setActiveState(DEFAULT_START_STATE);
Thread newThread = new Thread(robotsThreads, newRobot, "Bot-" + newRobot.getSerialNumber());
newThread.start(); // jumpstarts the robot
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.