code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
private void open() throws ModbusIOException {
if (commPort != null && !commPort.isOpen()) {
setTimeout(timeout);
try {
commPort.open();
}
catch (IOException e) {
throw new ModbusIOException(String.format("Cannot open port %s - %s",... | java |
protected void readEcho(int len) throws IOException {
byte echoBuf[] = new byte[len];
int echoLen = commPort.readBytes(echoBuf, len);
if (logger.isDebugEnabled()) {
logger.debug("Echo: {}", ModbusUtil.toHex(echoBuf, 0, echoLen));
}
if (echoLen != len) {
lo... | java |
protected int readByte() throws IOException {
if (commPort != null && commPort.isOpen()) {
byte[] buffer = new byte[1];
int cnt = commPort.readBytes(buffer, 1);
if (cnt != 1) {
throw new IOException("Cannot read from serial port");
}
el... | java |
void readBytes(byte[] buffer, long bytesToRead) throws IOException {
if (commPort != null && commPort.isOpen()) {
int cnt = commPort.readBytes(buffer, bytesToRead);
if (cnt != bytesToRead) {
throw new IOException("Cannot read from serial port - truncated");
}
... | java |
final int writeBytes(byte[] buffer, long bytesToWrite) throws IOException {
if (commPort != null && commPort.isOpen()) {
return commPort.writeBytes(buffer, bytesToWrite);
}
else {
throw new IOException("Comm port is not valid or not open");
}
} | java |
int readAsciiByte() throws IOException {
if (commPort != null && commPort.isOpen()) {
byte[] buffer = new byte[1];
int cnt = commPort.readBytes(buffer, 1);
if (cnt != 1) {
throw new IOException("Cannot read from serial port");
}
else if... | java |
int writeAsciiBytes(byte[] buffer, long bytesToWrite) throws IOException {
if (commPort != null && commPort.isOpen()) {
int cnt = 0;
for (int i = 0; i < bytesToWrite; i++) {
if (writeAsciiByte(buffer[i]) != 2) {
return cnt;
}
... | java |
void clearInput() throws IOException {
if (commPort.bytesAvailable() > 0) {
int len = commPort.bytesAvailable();
byte buf[] = new byte[len];
readBytes(buf, len);
if (logger.isDebugEnabled()) {
logger.debug("Clear input: {}", ModbusUtil.toHex(buf, 0... | java |
void waitBetweenFrames(int transDelayMS, long lastTransactionTimestamp) {
// If a fixed delay has been set
if (transDelayMS > 0) {
ModbusUtil.sleep(transDelayMS);
}
else {
// Make use we have a gap of 3.5 characters between adjacent requests
// We hav... | java |
long getCharIntervalMicro(double chars) {
// Make use we have a gap of 3.5 characters between adjacent requests
// We have to do the calculations here because it is possible that the caller may have changed
// the connection characteristics if they provided the connection instance
return... | java |
boolean spinUntilBytesAvailable(long waitTimeMicroSec) {
long start = System.nanoTime();
while (availableBytes() < 1) {
long delta = System.nanoTime() - start;
if (delta > waitTimeMicroSec * 1000) {
return false;
}
}
return true;
} | java |
public void open() throws ModbusException {
// Start the listener if it isn' already running
if (!isRunning) {
try {
listenerThread = new Thread(listener);
listenerThread.start();
isRunning = true;
}
catch (Exception x... | java |
@SuppressWarnings("deprecation")
void closeListener() {
if (listener != null && listener.isListening()) {
listener.stop();
// Wait until the listener says it has stopped, but don't wait forever
int count = 0;
while (listenerThread != null && listenerThread.is... | java |
void handleRequest(AbstractModbusTransport transport, AbstractModbusListener listener) throws ModbusIOException {
// Get the request from the transport. It will be processed
// using an associated process image
if (transport == null) {
throw new ModbusIOException("No transport spec... | java |
public ProcessImage getProcessImage(int unitId) {
ModbusSlave slave = ModbusSlaveFactory.getSlave(this);
if (slave != null) {
return slave.getProcessImage(unitId);
}
return null;
} | java |
private static byte calculateLRC(byte[] data, int off, int length, int tailskip) {
int lrc = 0;
for (int i = off; i < length - tailskip; i++) {
lrc += ((int) data[i]) & 0xFF;
}
return (byte) ((-lrc) & 0xff);
} | java |
public BitVector readCoils(int unitId, int ref, int count) throws ModbusException {
checkTransaction();
if (readCoilsRequest == null) {
readCoilsRequest = new ReadCoilsRequest();
}
readCoilsRequest.setUnitID(unitId);
readCoilsRequest.setReference(ref);
readCoi... | java |
public boolean writeCoil(int unitId, int ref, boolean state) throws ModbusException {
checkTransaction();
if (writeCoilRequest == null) {
writeCoilRequest = new WriteCoilRequest();
}
writeCoilRequest.setUnitID(unitId);
writeCoilRequest.setReference(ref);
write... | java |
public void writeMultipleCoils(int unitId, int ref, BitVector coils) throws ModbusException {
checkTransaction();
if (writeMultipleCoilsRequest == null) {
writeMultipleCoilsRequest = new WriteMultipleCoilsRequest();
}
writeMultipleCoilsRequest.setUnitID(unitId);
write... | java |
public BitVector readInputDiscretes(int unitId, int ref, int count) throws ModbusException {
checkTransaction();
if (readInputDiscretesRequest == null) {
readInputDiscretesRequest = new ReadInputDiscretesRequest();
}
readInputDiscretesRequest.setUnitID(unitId);
readIn... | java |
public InputRegister[] readInputRegisters(int unitId, int ref, int count) throws ModbusException {
checkTransaction();
if (readInputRegistersRequest == null) {
readInputRegistersRequest = new ReadInputRegistersRequest();
}
readInputRegistersRequest.setUnitID(unitId);
... | java |
public Register[] readMultipleRegisters(int unitId, int ref, int count) throws ModbusException {
checkTransaction();
if (readMultipleRegistersRequest == null) {
readMultipleRegistersRequest = new ReadMultipleRegistersRequest();
}
readMultipleRegistersRequest.setUnitID(unitId)... | java |
public int writeSingleRegister(int unitId, int ref, Register register) throws ModbusException {
checkTransaction();
if (writeSingleRegisterRequest == null) {
writeSingleRegisterRequest = new WriteSingleRegisterRequest();
}
writeSingleRegisterRequest.setUnitID(unitId);
... | java |
public int writeMultipleRegisters(int unitId, int ref, Register[] registers) throws ModbusException {
checkTransaction();
if (writeMultipleRegistersRequest == null) {
writeMultipleRegistersRequest = new WriteMultipleRegistersRequest();
}
writeMultipleRegistersRequest.setUnitI... | java |
private ModbusResponse getAndCheckResponse() throws ModbusException {
ModbusResponse res = transaction.getResponse();
if (res == null) {
throw new ModbusException("No response");
}
return res;
} | java |
public static AbstractSerialConnection getCommPort(String commPort) {
SerialConnection jSerialCommPort = new SerialConnection();
jSerialCommPort.serialPort = SerialPort.getCommPort(commPort);
return jSerialCommPort;
} | java |
public void attachNettyPromise(Promise<T> promise) {
promise.addListener(promiseHandler);
Promise<T> oldPromise = this.promise;
this.promise = promise;
if (oldPromise != null) {
oldPromise.removeListener(promiseHandler);
oldPromise.cancel(true);
}
} | java |
public void addListener(IsSimplePromiseResponseHandler<T> listener) {
if (handlers == null) {
handlers = new LinkedList<>();
}
handlers.add(listener);
if (response != null || exception != null) {
listener.onResponse(this);
}
} | java |
protected void handlePromise(Promise<T> promise) {
if (!promise.isSuccess()) {
this.setException(promise.cause());
} else {
this.response = promise.getNow();
if (handlers != null) {
for (IsSimplePromiseResponseHandler<T> h : handlers) {
h.onResponse(this);
}
}
... | java |
protected void waitForPromiseSuccess() throws IOException, TimeoutException {
while(!promise.isDone() && !promise.isCancelled()) {
Promise<T> listeningPromise = this.promise;
listeningPromise.awaitUninterruptibly();
if (listeningPromise == this.promise) {
this.handlePromise(promise);
... | java |
public void handleRetry(Throwable cause) {
try {
this.retryPolicy.retry(connectionState, retryHandler, connectionFailHandler);
} catch (RetryPolicy.RetryCancelled retryCancelled) {
this.getNettyPromise().setFailure(cause);
}
} | java |
public EtcdSelfStatsResponse getSelfStats() {
try {
return new EtcdSelfStatsRequest(this.client, retryHandler).send().get();
} catch (IOException | EtcdException | EtcdAuthenticationException | TimeoutException e) {
return null;
}
} | java |
public EtcdLeaderStatsResponse getLeaderStats() {
try {
return new EtcdLeaderStatsRequest(this.client, retryHandler).send().get();
} catch (IOException | EtcdException | EtcdAuthenticationException | TimeoutException e) {
return null;
}
} | java |
public EtcdStoreStatsResponse getStoreStats() {
try {
return new EtcdStoreStatsRequest(this.client, retryHandler).send().get();
} catch (IOException | EtcdException | EtcdAuthenticationException | TimeoutException e) {
return null;
}
} | java |
public EtcdKeyPutRequest put(String key, String value) {
return new EtcdKeyPutRequest(client, key, retryHandler).value(value);
} | java |
public EtcdKeyPostRequest post(String key, String value) {
return new EtcdKeyPostRequest(client, key, retryHandler).value(value);
} | java |
public static SslContext forKeystore(String keystorePath, String keystorePassword)
throws SecurityContextException {
return forKeystore(keystorePath, keystorePassword, "SunX509");
} | java |
public static SslContext forKeystoreAndTruststore(InputStream keystore, String keystorePassword, InputStream truststore, String truststorePassword, String keyManagerAlgorithm)
throws SecurityContextException {
try {
final KeyStore ks = KeyStore.getInstance(KEYSTORE_JKS);
fina... | java |
public <R> EtcdResponsePromise<R> send(final EtcdRequest<R> etcdRequest) throws IOException {
ConnectionState connectionState = new ConnectionState(uris, lastWorkingUriIndex);
if (etcdRequest.getPromise() == null) {
etcdRequest.setPromise(new EtcdResponsePromise<R>(
etcdRequest.getRetryPolicy(),
... | java |
private <R> void modifyPipeLine(final EtcdRequest<R> req, final ChannelPipeline pipeline) {
final EtcdResponseHandler<R> handler = new EtcdResponseHandler<>(this, req);
if (req.hasTimeout()) {
pipeline.addFirst(new ReadTimeoutHandler(req.getTimeout(), req.getTimeoutUnit()));
}
pipeline.addLast(h... | java |
private <R> ChannelFuture createAndSendHttpRequest(URI server, String uri, EtcdRequest<R> etcdRequest, Channel channel) throws Exception {
HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, etcdRequest.getMethod(), uri);
httpRequest.headers().add(HttpHeaderNames.CONNECTION, "keep-alive");
... | java |
public EtcdKeyPutRequest refresh(Integer ttl) {
this.requestParams.put("refresh", "true");
this.prevExist(true);
return ttl(ttl);
} | java |
public final void retry(final ConnectionState state, final RetryHandler retryHandler, final ConnectionFailHandler failHandler) throws RetryCancelled {
if (state.retryCount == 0) {
state.msBeforeRetry = this.startRetryTime;
}
state.retryCount++;
state.uriIndex = state.retryCount % state.uris.lengt... | java |
public EtcdNettyConfig setEventLoopGroup(EventLoopGroup eventLoopGroup, boolean managed) {
if (this.eventLoopGroup != null && this.managedEventLoopGroup) { // if i manage it, close the old when new one come
this.eventLoopGroup.shutdownGracefully();
}
this.eventLoopGroup = eventLoopGroup;
this.mana... | java |
public static URI[] fromDNSName(String srvName) throws NamingException {
List<URI> uris = new ArrayList<>();
Hashtable<String, String> env = new Hashtable<>();
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
env.put("java.naming.provider.url", "dns:");
DirContext ctx =... | java |
public void setSlf4jLogname(String logName)
{
// use length() == 0 instead of isEmpty() for Java 5 compatibility
if( logName.length() == 0 )
{
m_log = null;
}
else
{
m_log = LoggerFactory.getLogger(logName);
}
} | java |
@Override
public void log(StopWatch sw)
{
//
// This avoids calling the possibly expensive sw.toString() method if logging is disabled.
//
if( m_log != null && m_log.isInfoEnabled() )
{
m_log.info(sw.toString());
}
} | java |
@Override
public void log(StopWatch sw)
{
if( !m_queue.offer( sw.freeze() ) ) m_rejectedStopWatches.getAndIncrement();
if( m_collectorThread == null )
{
synchronized(this)
{
//
// Ensure that there is no race condition starting th... | java |
private void rebuildJmx()
{
m_mbeanServer = ManagementFactory.getPlatformMBeanServer();
try
{
buildMBeanInfo();
//
// Remove and reinstall from the MBean registry if it already exists. Also
// remove previous instances.
//
... | java |
private boolean emptyQueue(long finalMoment)
{
StopWatch sw;
try
{
while( null != (sw = m_queue.poll(100, TimeUnit.MILLISECONDS)) )
{
// Ignore faulty StopWatches
if( sw.getTag() == null ) continue;
if... | java |
private static void configure()
{
String propertyFile = System.getProperty( SYSTEM_PROPERTY, PROPERTYFILENAME );
InputStream in = findConfigFile( propertyFile,
"/com/ecyrd/speed4j/default_speed4j.properties");
configure(in);
} | java |
@SuppressWarnings( "unchecked" )
private static synchronized void configure(InputStream in) throws ConfigurationException
{
if( c_factories == null )
c_factories = new HashMap<String, StopWatchFactory>();
try
{
c_config.load(in);
}
catch (IOExcept... | java |
public StopWatch getStopWatch( String tag, String message )
{
return new LoggingStopWatch( m_log, tag, message );
} | java |
public static synchronized void shutdown()
{
if( c_factories == null ) return; // Nothing to do
for( Iterator<Entry<String, StopWatchFactory>> i = c_factories.entrySet().iterator(); i.hasNext() ; )
{
Map.Entry<String,StopWatchFactory> e = i.next();
StopWatchFactory ... | java |
public static StopWatchFactory getInstance(String loggerName) throws ConfigurationException
{
StopWatchFactory swf = getFactories().get(loggerName);
if( swf == null ) throw new ConfigurationException("No logger by the name "+loggerName+" found.");
return swf;
} | java |
public StopWatch stop( String tag, String message )
{
m_tag = tag;
m_message = message;
stop();
return this;
} | java |
private String getReadableTime()
{
long ns = getTimeNanos();
if( ns < 50L * 1000 )
return ns + " ns";
if( ns < 50L * 1000 * 1000 )
return (ns/1000)+" us";
if( ns < 50L * 1000 * 1000 * 1000 )
return (ns/(1000*1000))+" ms";
return ns/NANO... | java |
public synchronized void add(StopWatch sw)
{
double timeInMs = sw.getTimeMicros() / MICROS_IN_MILLIS;
// let fake the array
for ( int i=0; i < sw.getCount() ; i++ )
m_times.add(timeInMs / sw.getCount());
if( timeInMs < m_min ) m_min = timeInMs;
if( timeInMs > m_ma... | java |
public PostBuilder withCategories(Term... terms) {
return withCategories(Arrays.stream(terms).map(Term::getId).collect(toList()));
} | java |
public PostBuilder withTags(Term... tags) {
return withTags(Arrays.stream(tags).map(Term::getId).collect(toList()));
} | java |
public static E164PhoneNumberWithExtension ofPhoneNumberStringAndExtension(String phoneNumber, String extension, CountryCode defaultCountryCode) {
return new E164PhoneNumberWithExtension(phoneNumber, extension, defaultCountryCode);
} | java |
@SuppressWarnings("unchecked")
public static final <C> FieldModel<C> get(Field f, FieldAccess<C> fieldAccess) {
String fieldModelKey = (fieldAccess.getClass().getSimpleName() + ":" + f.getClass().getName() + "#" + f.getName());
FieldModel<C> fieldModel = (FieldModel<C>)fieldModels.get(fieldModelKey);
if ... | java |
public boolean isImmutable(Class<?> clazz) {
if (clazz.isPrimitive() || clazz.isEnum()) {
return false;
}
if (clazz.isArray()) {
return false;
}
final IsImmutable isImmutable;
if (DETECTED_IMMUTABLE_CLASSES.containsKey(clazz)) {
... | java |
public static <E> Iterable<E> wrapEnumeration(Enumeration<E> enumeration) {
return new IterableEnumeration<E>(enumeration);
} | java |
public static BindingConfiguration load(URL location) throws IllegalStateException {
Document doc;
try {
doc = loadDocument(location);
} catch (IOException e) {
throw new IllegalStateException("Cannot load " + location.toExternalForm(), e);
} catch (P... | java |
private static Document loadDocument(URL location) throws IOException, ParserConfigurationException, SAXException {
InputStream inputStream = null;
if (location != null) {
URLConnection urlConnection = location.openConnection();
urlConnection.setUseCaches(false);
... | java |
private static DocumentBuilder constructDocumentBuilder(List<SAXParseException> errors)
throws ParserConfigurationException {
DocumentBuilderFactory documentBuilderFactory = constructDocumentBuilderFactory();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
... | java |
private static Provider parseProviderElement(Element element) {
Class<?> providerClass = lookupClass(element.getAttribute("class"));
if (providerClass == null) {
throw new IllegalStateException("Referenced class {" + element.getAttribute("class")
+ "} could not be... | java |
private static <T> Extension<T> parseBinderExtensionElement(Element element) {
@SuppressWarnings("unchecked")
Class<T> providerClass = (Class<T>)lookupClass(element.getAttribute("class"));
Class<?> implementationClass = lookupClass(element.getAttribute("implementationClass"));
... | java |
private static Class<?> lookupClass(String elementName) {
Class<?> clazz = null;
try {
clazz = ClassLoaderUtils.getClassLoader().loadClass(elementName);
} catch (ClassNotFoundException e) {
return null;
}
return clazz;
} | java |
private <T> Class<? extends Annotation> matchAnnotationToScope(Annotation[] annotations) {
for (Annotation next : annotations) {
Class<? extends Annotation> nextType = next.annotationType();
if (nextType.getAnnotation(BindingScope.class) != null) {
return nextType;
... | java |
protected String constructMessage(String message, Throwable cause) {
if (cause != null) {
StringBuilder strBuilder = new StringBuilder();
if (message != null) {
strBuilder.append(message).append(": ");
}
strBuilder.append("Wrapped exception is {").append(cause);
strBuilder.append("}")... | java |
public Throwable getRootCause() {
Throwable rootCause = null;
Throwable nextCause = getCause();
while (nextCause != null && !nextCause.equals(rootCause)) {
rootCause = nextCause;
nextCause = nextCause.getCause();
}
return rootCause;
} | java |
public <E extends Exception> E findWrapped(Class<E> exceptionType) {
if (exceptionType == null) {
return null;
}
Throwable cause = getCause();
while (true) {
if (cause == null) {
return null;
}
if (exceptionType.isInstance(cause)) {
@SuppressWarnings("unchecked") E matc... | java |
public void beforeNullSafeOperation(SharedSessionContractImplementor session) {
ConfigurationHelper.setCurrentSessionFactory(session.getFactory());
if (this instanceof IntegratorConfiguredType) {
((IntegratorConfiguredType)this).applyConfiguration(session.getFactory());
}
} | java |
private void initJdkBindings() {
registerBinding(AtomicBoolean.class, String.class, new AtomicBooleanStringBinding());
registerBinding(AtomicInteger.class, String.class, new AtomicIntegerStringBinding());
registerBinding(AtomicLong.class, String.class, new AtomicLongStringBinding())... | java |
protected <X> void registerConfigurations(Enumeration<URL> bindingsConfiguration) {
List<BindingConfiguration> configs = new ArrayList<BindingConfiguration>();
for (URL nextLocation : IterableEnumeration.wrapEnumeration(bindingsConfiguration)) {
// Filter built in bindings - th... | java |
protected void registerBindingConfigurationEntries(Iterable<BindingConfigurationEntry> bindings) {
for (BindingConfigurationEntry nextBinding : bindings) {
try {
registerBindingConfigurationEntry(nextBinding);
} catch (IllegalStateException e) {
// Ignore this - it c... | java |
public void registerAnnotatedClasses(Class<?>... classesToInspect) {
for (Class<?> nextClass : classesToInspect) {
Class<?> loopClass = nextClass;
while ((loopClass != Object.class) && (!inspectedClasses.contains(loopClass))) {
attachForAnnotations(loopClass);
loopClass = loopClass.g... | java |
protected <I, T extends I> void registerExtendedBinder(Class<I> iface, T provider) {
extendedBinders.put(iface, provider);
} | java |
@SuppressWarnings("unchecked")
protected <I> I getExtendedBinder(Class<I> cls) {
return (I) extendedBinders.get(cls);
} | java |
public static boolean isJdkImmutable(Class<?> type) {
if (Class.class == type) {
return true;
}
if (String.class == type) {
return true;
}
if (BigInteger.class == type) {
return true;
}
if (BigDecimal.class == type) {
r... | java |
public static boolean isWrapper(Class<?> type) {
if (Boolean.class == type) {
return true;
}
if (Byte.class == type) {
return true;
}
if (Character.class == type) {
return true;
}
if (Short.class == type) {
retur... | java |
public static Field[] collectInstanceFields(Class<?> c, Class<?> limitExclusive) {
return collectFields(c, 0, Modifier.STATIC, limitExclusive);
} | java |
protected final Class<T> getEntityClass() {
@SuppressWarnings("unchecked")
final Class<T> result = (Class<T>) TypeHelper.getTypeArguments(JpaSearchRepository.class, this.getClass()).get(0);
return result;
} | java |
protected final Class<ID> getIdClass() {
@SuppressWarnings("unchecked")
final Class<ID> result = (Class<ID>) TypeHelper.getTypeArguments(JpaSearchRepository.class, this.getClass()).get(1);
return result;
} | java |
protected T getSingleResult(Query q) {
try {
@SuppressWarnings("unchecked")
T retVal = (T) q.getSingleResult();
return retVal;
} catch (NoResultException e) {
return null;
}
} | java |
public static Class<?> classForName(String name) throws ClassNotFoundException {
ClassLoader cl = getClassLoader();
try {
if (cl != null) {
return cl.loadClass(name);
}
} catch (ClassNotFoundException e) {
// Ignore and try using Class.forName()
}
return Class.forName(name);
} | java |
public static Class<?> classForName(String name,
ClassLoader... classLoaders) throws ClassNotFoundException {
ClassLoader[] cls = getClassLoaders(classLoaders);
for (ClassLoader cl : cls) {
try {
if (cl != null) {
return cl.loadClass(name);
}
} catch (ClassNotFoundException e) {
... | java |
protected <T> T performCloneForCloneableMethod(T object, CloneDriver context) {
Class<?> clazz = object.getClass();
final T result;
try {
MethodHandle handle = context.getCloneMethod(clazz);
result = (T) handle.invoke(object);
} catch (Throwable e) {
throw new IllegalStateException("Could not invoke ... | java |
protected <T> void handleCloneField(T obj, T copy, CloneDriver driver, FieldModel<T> f, IdentityHashMap<Object, Object> referencesToReuse, long stackDepth) {
final Class<?> clazz = f.getFieldClass();
if (clazz.isPrimitive()) {
handleClonePrimitiveField(obj, copy, driver, f, referencesToReuse);
} else if (!dr... | java |
@SuppressWarnings("unchecked")
public static final <C> ClassModel<C> get(ClassAccess<C> classAccess) {
Class<?> clazz = classAccess.getType();
String classModelKey = (classAccess.getClass().getName() + ":" + clazz.getName());
ClassModel<C> classModel = (ClassModel<C>)classModels.get(classModelKey)... | java |
private void initializeBuiltInImplementors() {
builtInImplementors.put(ArrayList.class, new ArrayListImplementor());
builtInImplementors.put(ConcurrentHashMap.class, new ConcurrentHashMapImplementor());
builtInImplementors.put(GregorianCalendar.class, new GregorianCalendarImplementor());
builtInImplementors.put... | java |
public void setImplementors(Map<Class<?>, CloneImplementor> implementors) {
// this.implementors = implementors;
this.allImplementors = new HashMap<Class<?>, CloneImplementor>();
allImplementors.putAll(builtInImplementors);
allImplementors.putAll(implementors);
} | java |
public static String removeWhitespace(String string) {
if (string == null || string.length() == 0) {
return string;
} else {
int codePoints = string.codePointCount(0, string.length());
StringBuilder sb = new StringBuilder();
for (int i = 0; i < c... | java |
public static final AccessClassLoader get(Class<?> typeToBeExtended) {
ClassLoader loader = typeToBeExtended.getClassLoader();
return get(loader == null ? ClassLoader.getSystemClassLoader() : loader);
} | java |
public synchronized static final AccessClassLoader get(ClassLoader parent) {
AccessClassLoader loader = (AccessClassLoader) ASM_CLASS_LOADERS.get(parent);
if (loader == null) {
loader = new AccessClassLoader(parent);
ASM_CLASS_LOADERS.put(parent, loader);
}
return loader;
} | java |
public void registerClass(String name, byte[] bytes) {
if (registeredClasses.containsKey(name)) {
throw new IllegalStateException("Attempted to register a class that has been registered already: " + name);
}
registeredClasses.put(name, bytes);
} | java |
public boolean isPatterned() {
final boolean result;
if (pattern.indexOf('*') != -1 || pattern.indexOf('?') != -1) {
result = true;
} else {
result = false;
}
return result;
} | java |
public static <C> InvokeDynamicClassAccess<C> get(Class<C> clazz) {
@SuppressWarnings("unchecked")
InvokeDynamicClassAccess<C> access = (InvokeDynamicClassAccess<C>) CLASS_ACCESSES.get(clazz);
if (access != null) {
return access;
}
Class<?> enclosingType = c... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.