code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
private JsonParserException createHelpfulException(char first, char[] expected, int failurePosition)
throws JsonParserException {
// Build the first part of the token
StringBuilder errorToken = new StringBuilder(first
+ (expected == null ? "" : new String(expected, 0, failurePosition)));
// C... | java |
public void capture (CaptureMode mode) {
assert dispatchLayer != null;
if (canceled) throw new IllegalStateException("Cannot capture canceled interaction.");
if (capturingLayer != dispatchLayer && captured()) throw new IllegalStateException(
"Interaction already captured by " + capturingLayer);
ca... | java |
public void begin (float fbufWidth, float fbufHeight, boolean flip) {
if (begun) throw new IllegalStateException(getClass().getSimpleName() + " mismatched begin()");
begun = true;
} | java |
public static void registerVariant(String name, Style style, String variantName) {
Map<String,String> styleVariants = _variants.get(style);
if (styleVariants == null) {
_variants.put(style, styleVariants = new HashMap<String,String>());
}
styleVariants.put(name, variantName);
} | java |
public static FloatBuffer allocate (int capacity) {
if (capacity < 0) {
throw new IllegalArgumentException();
}
ByteBuffer bb = ByteBuffer.allocateDirect(capacity * 4);
bb.order(ByteOrder.nativeOrder());
return bb.asFloatBuffer();
} | java |
public int compareTo (FloatBuffer otherBuffer) {
int compareRemaining = (remaining() < otherBuffer.remaining()) ?
remaining() : otherBuffer.remaining();
int thisPos = position;
int otherPos = otherBuffer.position;
// BEGIN android-changed
float thisFloat, otherFloat;
... | java |
@SuppressWarnings("rawtypes")
public Class<? extends TBase> getMessageClass(String topic) {
return allTopics ? messageClassForAll : messageClassByTopic.get(topic);
} | java |
public void init(SecorConfig config, OffsetTracker offsetTracker, FileRegistry fileRegistry,
UploadManager uploadManager, MessageReader messageReader, MetricCollector metricCollector,
DeterministicUploadPolicyTracker deterministicUploadPolicyTracker) {
init(config, offs... | java |
public void init(SecorConfig config, OffsetTracker offsetTracker, FileRegistry fileRegistry,
UploadManager uploadManager, MessageReader messageReader,
ZookeeperConnector zookeeperConnector, MetricCollector metricCollector,
DeterministicUploadPolicyTracker d... | java |
protected FileReader createReader(LogFilePath srcPath, CompressionCodec codec) throws Exception {
return ReflectionUtil.createFileReader(
mConfig.getFileReaderWriterFactory(),
srcPath,
codec,
mConfig
);
} | java |
public void applyPolicy(boolean forceUpload) throws Exception {
Collection<TopicPartition> topicPartitions = mFileRegistry.getTopicPartitions();
for (TopicPartition topicPartition : topicPartitions) {
checkTopicPartition(topicPartition, forceUpload);
}
} | java |
private CompressionKind resolveCompression(CompressionCodec codec) {
if (codec instanceof Lz4Codec)
return CompressionKind.LZ4;
else if (codec instanceof SnappyCodec)
return CompressionKind.SNAPPY;
// although GZip and ZLIB are not same thing
// there is no better... | java |
private FileReader createFileReader(LogFilePath logFilePath) throws Exception {
CompressionCodec codec = null;
if (mConfig.getCompressionCodec() != null && !mConfig.getCompressionCodec().isEmpty()) {
codec = CompressionUtil.createCompressionCodec(mConfig.getCompressionCodec());
}
... | java |
public Class<? extends Message> getMessageClass(String topic) {
return allTopics ? messageClassForAll : messageClassByTopic.get(topic);
} | java |
public Message decodeProtobufMessage(String topic, byte[] payload){
Method parseMethod = allTopics ? messageParseMethodForAll : messageParseMethodByTopic.get(topic);
try {
return (Message) parseMethod.invoke(null, payload);
} catch (IllegalArgumentException e) {
throw new... | java |
public Message decodeProtobufOrJsonMessage(String topic, byte[] payload) {
try {
if (shouldDecodeFromJsonMessage(topic)) {
return decodeJsonMessage(topic, payload);
}
} catch (InvalidProtocolBufferException e) {
//When trimming files, the Uploader will... | java |
public static UploadManager createUploadManager(String className,
SecorConfig config) throws Exception {
Class<?> clazz = Class.forName(className);
if (!UploadManager.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(Strin... | java |
public static Uploader createUploader(String className) throws Exception {
Class<?> clazz = Class.forName(className);
if (!Uploader.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(String.format("The class '%s' is not assignable to '%s'.",
className, Up... | java |
public static MessageParser createMessageParser(String className,
SecorConfig config) throws Exception {
Class<?> clazz = Class.forName(className);
if (!MessageParser.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(Strin... | java |
private static FileReaderWriterFactory createFileReaderWriterFactory(String className,
SecorConfig config) throws Exception {
Class<?> clazz = Class.forName(className);
if (!FileReaderWriterFactory.class.isAssignableFrom(clazz)) {
... | java |
public static FileWriter createFileWriter(String className, LogFilePath logFilePath,
CompressionCodec codec,
SecorConfig config)
throws Exception {
return createFileReaderWriterFactory(className, config).Buil... | java |
public static FileReader createFileReader(String className, LogFilePath logFilePath,
CompressionCodec codec,
SecorConfig config)
throws Exception {
return createFileReaderWriterFactory(className, config).Buil... | java |
public static MessageTransformer createMessageTransformer(
String className, SecorConfig config) throws Exception {
Class<?> clazz = Class.forName(className);
if (!MessageTransformer.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(String.format(
... | java |
public static ORCSchemaProvider createORCSchemaProvider(
String className, SecorConfig config) throws Exception {
Class<?> clazz = Class.forName(className);
if (!ORCSchemaProvider.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(String.format(
... | java |
public static String getMd5Hash(String topic, String[] partitions) {
ArrayList<String> elements = new ArrayList<String>();
elements.add(topic);
for (String partition : partitions) {
elements.add(partition);
}
String pathPrefix = StringUtils.join(elements, "/");
try {
... | java |
private void setSchemas(SecorConfig config) {
Map<String, String> schemaPerTopic = config.getORCMessageSchema();
for (Entry<String, String> entry : schemaPerTopic.entrySet()) {
String topic = entry.getKey();
TypeDescription schema = TypeDescription.fromString(entry
... | java |
public Map<String, String> getPropertyMapForPrefix(String prefix) {
Iterator<String> keys = mProperties.getKeys(prefix);
Map<String, String> map = new HashMap<String, String>();
while (keys.hasNext()) {
String key = keys.next();
String value = mProperties.getString(key);
... | java |
private void exportToStatsD(List<Stat> stats) {
// group stats by kafka group
for (Stat stat : stats) {
@SuppressWarnings("unchecked")
Map<String, String> tags = (Map<String, String>) stat.get(Stat.STAT_KEYS.TAGS.getName());
long value = Long.parseLong((String) stat.g... | java |
public Collection<TopicPartition> getTopicPartitions() {
Collection<TopicPartitionGroup> topicPartitions = getTopicPartitionGroups();
Set<TopicPartition> tps = new HashSet<TopicPartition>();
if (topicPartitions != null) {
for (TopicPartitionGroup g : topicPartitions) {
... | java |
public Collection<LogFilePath> getPaths(TopicPartitionGroup topicPartitionGroup) {
HashSet<LogFilePath> logFilePaths = mFiles.get(topicPartitionGroup);
if (logFilePaths == null) {
return new HashSet<LogFilePath>();
}
return new HashSet<LogFilePath>(logFilePaths);
} | java |
public FileWriter getOrCreateWriter(LogFilePath path, CompressionCodec codec)
throws Exception {
FileWriter writer = mWriters.get(path);
if (writer == null) {
// Just in case.
FileUtil.delete(path.getLogFilePath());
FileUtil.delete(path.getLogFileCrcPath()... | java |
public void deletePath(LogFilePath path) throws IOException {
TopicPartitionGroup topicPartition = new TopicPartitionGroup(path.getTopic(),
path.getKafkaPartitions());
HashSet<LogFilePath> paths = mFiles.get(topicPartition);
paths.remove... | java |
public void deleteWriter(LogFilePath path) throws IOException {
FileWriter writer = mWriters.get(path);
if (writer == null) {
LOG.warn("No writer found for path {}", path.getLogFilePath());
} else {
LOG.info("Deleting writer for path {}", path.getLogFilePath());
... | java |
public static void unregisterProgressListener(@NonNull final Context context, @NonNull final DfuProgressListener listener) {
if (mProgressBroadcastReceiver != null) {
final boolean empty = mProgressBroadcastReceiver.removeProgressListener(listener);
if (empty) {
LocalBroadcastManager.getInstance(context).u... | java |
public static void unregisterLogListener(@NonNull final Context context, @NonNull final DfuLogListener listener) {
if (mLogBroadcastReceiver != null) {
final boolean empty = mLogBroadcastReceiver.removeLogListener(listener);
if (empty) {
LocalBroadcastManager.getInstance(context).unregisterReceiver(mLogBro... | java |
public void fullReset() {
// Reset stream to SoftDevice if SD and BL firmware were given separately
if (softDeviceBytes != null && bootloaderBytes != null && currentSource == bootloaderBytes) {
currentSource = softDeviceBytes;
}
// Reset the bytes count to 0
bytesReadFromCurrentSource = 0;
mark(0);
res... | java |
void writeInitData(final BluetoothGattCharacteristic characteristic, final CRC32 crc32)
throws DfuException, DeviceDisconnectedException, UploadAbortedException {
try {
byte[] data = mBuffer;
int size;
while ((size = mInitPacketStream.read(data, 0, data.length)) != -1) {
writeInitPacket(characteristic... | java |
void uploadFirmwareImage(final BluetoothGattCharacteristic packetCharacteristic)
throws DeviceDisconnectedException, DfuException, UploadAbortedException {
if (mAborted)
throw new UploadAbortedException();
mReceivedData = null;
mError = 0;
mFirmwareUploadInProgress = true;
mPacketsSentSinceNotification ... | java |
private void writePacket(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final byte[] buffer, final int size) {
byte[] locBuffer = buffer;
if (size <= 0) // This should never happen
return;
if (buffer.length != size) {
locBuffer = new byte[size];
System.arraycopy(buffer, 0, lo... | java |
private int readVersion(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic)
throws DeviceDisconnectedException, DfuException, UploadAbortedException {
if (!mConnected)
throw new DeviceDisconnectedException("Unable to read version number: device disconnected");
if (mAborted)
... | java |
private boolean createBondApi18(@NonNull final BluetoothDevice device) {
/*
* There is a createBond() method in BluetoothDevice class but for now it's hidden. We will call it using reflections. It has been revealed in KitKat (Api19)
*/
try {
final Method createBond = device.getClass().getMethod("createBond... | java |
@SuppressWarnings("UnusedReturnValue")
boolean removeBond() {
final BluetoothDevice device = mGatt.getDevice();
if (device.getBondState() == BluetoothDevice.BOND_NONE)
return true;
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_VERBOSE, "Removing bond information...");
boolean result = false;
/*
... | java |
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
void requestMtu(@IntRange(from = 0, to = 517) final int mtu)
throws DeviceDisconnectedException, UploadAbortedException {
if (mAborted)
throw new UploadAbortedException();
mRequestCompleted = false;
mService.sendLogBroadcast(DfuBaseService.LOG_LEVE... | java |
byte[] readNotificationResponse()
throws DeviceDisconnectedException, DfuException, UploadAbortedException {
// do not clear the mReceiveData here. The response might already be obtained. Clear it in write request instead.
try {
synchronized (mLock) {
while ((mReceivedData == null && mConnected &... | java |
void restartService(@NonNull final Intent intent, final boolean scanForBootloader) {
String newAddress = null;
if (scanForBootloader) {
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_VERBOSE, "Scanning for the DFU Bootloader...");
newAddress = BootloaderScannerFactory.getScanner().searchFor(mGatt.getDevic... | java |
public DfuServiceInitiator setZip(@Nullable final Uri uri, @Nullable final String path) {
return init(uri, path, 0, DfuBaseService.TYPE_AUTO, DfuBaseService.MIME_TYPE_ZIP);
} | java |
public DfuServiceController start(@NonNull final Context context, @NonNull final Class<? extends DfuBaseService> service) {
if (fileType == -1)
throw new UnsupportedOperationException("You must specify the firmware file before starting the service");
final Intent intent = new Intent(context, service);
intent... | java |
private void setObjectSize(@NonNull final byte[] data, final int value) {
data[2] = (byte) (value & 0xFF);
data[3] = (byte) ((value >> 8) & 0xFF);
data[4] = (byte) ((value >> 16) & 0xFF);
data[5] = (byte) ((value >> 24) & 0xFF);
} | java |
private void writeCreateRequest(final int type, final int size)
throws DeviceDisconnectedException, DfuException, UploadAbortedException, RemoteDfuException,
UnknownResponseException {
if (!mConnected)
throw new DeviceDisconnectedException("Unable to create object: device disconnected");
final byte[] data... | java |
private ObjectInfo selectObject(final int type)
throws DeviceDisconnectedException, DfuException, UploadAbortedException,
RemoteDfuException, UnknownResponseException {
if (!mConnected)
throw new DeviceDisconnectedException("Unable to read object info: device disconnected");
OP_CODE_SELECT_OBJECT[1] = (by... | java |
private ObjectChecksum readChecksum() throws DeviceDisconnectedException, DfuException,
UploadAbortedException, RemoteDfuException, UnknownResponseException {
if (!mConnected)
throw new DeviceDisconnectedException("Unable to read Checksum: device disconnected");
writeOpCode(mControlPointCharacterist... | java |
private void writeExecute() throws DfuException, DeviceDisconnectedException,
UploadAbortedException, UnknownResponseException, RemoteDfuException {
if (!mConnected)
throw new DeviceDisconnectedException("Unable to read Checksum: device disconnected");
writeOpCode(mControlPointCharacteristic, OP_COD... | java |
public static BootloaderScanner getScanner() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
return new BootloaderScannerLollipop();
return new BootloaderScannerJB();
} | java |
private InputStream openInputStream(@NonNull final String filePath, final String mimeType, final int mbrSize, final int types)
throws IOException {
final InputStream is = new FileInputStream(filePath);
if (MIME_TYPE_ZIP.equals(mimeType))
return new ArchiveInputStream(is, mbrSize, types);
if (filePath.toLowe... | java |
private InputStream openInputStream(@NonNull final Uri stream, final String mimeType, final int mbrSize, final int types)
throws IOException {
final InputStream is = getContentResolver().openInputStream(stream);
if (MIME_TYPE_ZIP.equals(mimeType))
return new ArchiveInputStream(is, mbrSize, types);
final St... | java |
protected void terminateConnection(@NonNull final BluetoothGatt gatt, final int error) {
if (mConnectionState != STATE_DISCONNECTED) {
// Disconnect from the device
disconnect(gatt);
}
// Close the device
refreshDeviceCache(gatt, false); // This should be set to true when DFU Version is 0.5 or lower
cl... | java |
protected void waitFor(final int millis) {
synchronized (mLock) {
try {
sendLogBroadcast(DfuBaseService.LOG_LEVEL_DEBUG, "wait(" + millis + ")");
mLock.wait(millis);
} catch (final InterruptedException e) {
loge("Sleeping interrupted", e);
}
}
} | java |
protected void close(final BluetoothGatt gatt) {
logi("Cleaning up...");
sendLogBroadcast(LOG_LEVEL_DEBUG, "gatt.close()");
gatt.close();
mConnectionState = STATE_CLOSED;
} | java |
protected void refreshDeviceCache(final BluetoothGatt gatt, final boolean force) {
/*
* If the device is bonded this is up to the Service Changed characteristic to notify Android that the services has changed.
* There is no need for this trick in that case.
* If not bonded, the Android should not keep the se... | java |
protected void updateProgressNotification(@NonNull final NotificationCompat.Builder builder, final int progress) {
// Add Abort action to the notification
if (progress != PROGRESS_ABORTED && progress != PROGRESS_COMPLETED) {
final Intent abortIntent = new Intent(BROADCAST_ACTION);
abortIntent.putExtra(EXTRA_A... | java |
private void report(final int error) {
sendErrorBroadcast(error);
if (mDisableNotification)
return;
// create or update notification:
final String deviceAddress = mDeviceAddress;
final String deviceName = mDeviceName != null ? mDeviceName : getString(R.string.dfu_unknown_name);
final NotificationCompa... | java |
@SuppressWarnings("UnusedReturnValue")
private boolean initialize() {
// For API level 18 and above, get a reference to BluetoothAdapter through
// BluetoothManager.
final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
if (bluetoothManager == null) {
loge... | java |
private int readLine() throws IOException {
// end of file reached
if (pos == -1)
return 0;
final InputStream in = this.in;
// temporary value
int b;
int lineSize, type, offset;
do {
// skip end of line
do {
b = in.read();
pos++;
} while (b == '\n' || b == '\r');
/*
* Each li... | java |
private int readVersion(@Nullable final BluetoothGattCharacteristic characteristic) {
// The value of this characteristic has been read before by LegacyButtonlessDfuImpl
return characteristic != null ? characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, 0) : 0;
} | java |
private void resetAndRestart(@NonNull final BluetoothGatt gatt, @NonNull final Intent intent)
throws DfuException, DeviceDisconnectedException, UploadAbortedException {
mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_WARNING, "Last upload interrupted. Restarting device...");
// Send 'jump to bootloader comman... | java |
public static JsiiObjectRef parse(final JsonNode objRef) {
if (!objRef.has(TOKEN_REF)) {
throw new JsiiException("Malformed object reference. Expecting " + TOKEN_REF);
}
return new JsiiObjectRef(objRef.get(TOKEN_REF).textValue(), objRef);
} | java |
public static JsiiObjectRef fromObjId(final String objId) {
ObjectNode node = JsonNodeFactory.instance.objectNode();
node.put(TOKEN_REF, objId);
return new JsiiObjectRef(objId, node);
} | java |
public void loadModule(final JsiiModule module) {
try {
String tarball = extractResource(module.getModuleClass(), module.getBundleResourceName(), null);
ObjectNode req = makeRequest("load");
req.put("tarball", tarball);
req.put("name", module.getModuleName());
... | java |
public void deleteObject(final JsiiObjectRef objRef) {
ObjectNode req = makeRequest("del", objRef);
this.runtime.requestResponse(req);
} | java |
public JsonNode getPropertyValue(final JsiiObjectRef objRef, final String property) {
ObjectNode req = makeRequest("get", objRef);
req.put("property", property);
return this.runtime.requestResponse(req).get("value");
} | java |
public void setPropertyValue(final JsiiObjectRef objRef, final String property, final JsonNode value) {
ObjectNode req = makeRequest("set", objRef);
req.put("property", property);
req.set("value", value);
this.runtime.requestResponse(req);
} | java |
public JsonNode getStaticPropertyValue(final String fqn, final String property) {
ObjectNode req = makeRequest("sget");
req.put("fqn", fqn);
req.put("property", property);
return this.runtime.requestResponse(req).get("value");
} | java |
public void setStaticPropertyValue(final String fqn, final String property, final JsonNode value) {
ObjectNode req = makeRequest("sset");
req.put("fqn", fqn);
req.put("property", property);
req.set("value", value);
this.runtime.requestResponse(req);
} | java |
public JsonNode callStaticMethod(final String fqn, final String method, final ArrayNode args) {
ObjectNode req = makeRequest("sinvoke");
req.put("fqn", fqn);
req.put("method", method);
req.set("args", args);
JsonNode resp = this.runtime.requestResponse(req);
return resp.g... | java |
public JsonNode callMethod(final JsiiObjectRef objRef, final String method, final ArrayNode args) {
ObjectNode req = makeRequest("invoke", objRef);
req.put("method", method);
req.set("args", args);
JsonNode resp = this.runtime.requestResponse(req);
return resp.get("result");
... | java |
public JsonNode endAsyncMethod(final JsiiPromise promise) {
ObjectNode req = makeRequest("end");
req.put("promiseid", promise.getPromiseId());
JsonNode resp = this.runtime.requestResponse(req);
if (resp == null) {
return null; // result is null
}
return resp.g... | java |
public List<Callback> pendingCallbacks() {
ObjectNode req = makeRequest("callbacks");
JsonNode resp = this.runtime.requestResponse(req);
JsonNode callbacksResp = resp.get("callbacks");
if (callbacksResp == null || !callbacksResp.isArray()) {
throw new JsiiException("Expectin... | java |
public void completeCallback(final Callback callback, final String error, final JsonNode result) {
ObjectNode req = makeRequest("complete");
req.put("cbid", callback.getCbid());
req.put("err", error);
req.set("result", result);
this.runtime.requestResponse(req);
} | java |
public JsonNode getModuleNames(final String moduleName) {
ObjectNode req = makeRequest("naming");
req.put("assembly", moduleName);
JsonNode resp = this.runtime.requestResponse(req);
return resp.get("naming");
} | java |
private ObjectNode makeRequest(final String api) {
ObjectNode req = JSON.objectNode();
req.put("api", api);
return req;
} | java |
private ObjectNode makeRequest(final String api, final JsiiObjectRef objRef) {
ObjectNode req = makeRequest(api);
req.set("objref", objRef.toJson());
return req;
} | java |
JsonNode requestResponse(final JsonNode request) {
try {
// write request
String str = request.toString();
this.stdin.write(str + "\n");
this.stdin.flush();
// read response
JsonNode resp = readNextResponse();
// throw if thi... | java |
private JsonNode processErrorResponse(final JsonNode resp) {
String errorMessage = resp.get("error").asText();
if (resp.has("stack")) {
errorMessage += "\n" + resp.get("stack").asText();
}
throw new JsiiException(errorMessage);
} | java |
private JsonNode processCallbackResponse(final JsonNode resp) {
if (this.callbackHandler == null) {
throw new JsiiException("Cannot process callback since callbackHandler was not set");
}
Callback callback = JsiiObjectMapper.treeToValue(resp.get("callback"), Callback.class);
... | java |
private void startRuntimeIfNeeded() {
if (childProcess != null) {
return;
}
// If JSII_DEBUG is set, enable traces.
String jsiiDebug = System.getenv("JSII_DEBUG");
if (jsiiDebug != null
&& !jsiiDebug.isEmpty()
&& !jsiiDebug.equalsIgnor... | java |
private void handshake() {
JsonNode helloResponse = this.readNextResponse();
if (!helloResponse.has("hello")) {
throw new JsiiException("Expecting 'hello' message from jsii-runtime");
}
String runtimeVersion = helloResponse.get("hello").asText();
assertVersionCompat... | java |
JsonNode readNextResponse() {
try {
String responseLine = this.stdout.readLine();
if (responseLine == null) {
String error = this.stderr.lines().collect(Collectors.joining("\n\t"));
throw new JsiiException("Child process exited unexpectedly: " + error);
... | java |
private void startPipeErrorStreamThread() {
Thread daemon = new Thread(() -> {
while (true) {
try {
String line = stderr.readLine();
System.err.println(line);
if (line == null) {
break;
... | java |
static void assertVersionCompatible(final String expectedVersion, final String actualVersion) {
final String shortActualVersion = actualVersion.replaceAll(VERSION_BUILD_PART_REGEX, "");
final String shortExpectedVersion = expectedVersion.replaceAll(VERSION_BUILD_PART_REGEX, "");
if (shortExpecte... | java |
private String prepareBundledRuntime() {
try {
String directory = Files.createTempDirectory("jsii-java-runtime").toString();
String entrypoint = extractResource(getClass(), "jsii-runtime.js", directory);
extractResource(getClass(), "jsii-runtime.js.map", directory);
... | java |
public void loadModule(final Class<? extends JsiiModule> moduleClass) {
if (!JsiiModule.class.isAssignableFrom(moduleClass)) {
throw new JsiiException("Invalid module class "
+ moduleClass.getName()
+ ". It must be derived from JsiiModule");
}
... | java |
public void registerObject(final JsiiObjectRef objRef, final Object obj) {
if (obj instanceof JsiiObject) {
((JsiiObject) obj).setObjRef(objRef);
}
this.objects.put(objRef.getObjId(), obj);
} | java |
public Object nativeFromObjRef(final JsiiObjectRef objRef) {
Object obj = this.objects.get(objRef.getObjId());
if (obj == null) {
obj = createNative(objRef.getFqn());
this.registerObject(objRef, obj);
}
return obj;
} | java |
public JsiiObjectRef nativeToObjRef(final Object nativeObject) {
if (nativeObject instanceof JsiiObject) {
return ((JsiiObject) nativeObject).getObjRef();
}
for (String objid : this.objects.keySet()) {
Object obj = this.objects.get(objid);
if (obj == nativeOb... | java |
public Object getObject(final JsiiObjectRef objRef) {
Object obj = this.objects.get(objRef.getObjId());
if (obj == null) {
throw new JsiiException("Cannot find jsii object: " + objRef.getObjId());
}
return obj;
} | java |
private Class<?> resolveJavaClass(final String fqn) throws ClassNotFoundException {
String[] parts = fqn.split("\\.");
if (parts.length < 2) {
throw new JsiiException("Malformed FQN: " + fqn);
}
String moduleName = parts[0];
JsonNode names = this.getClient().getModu... | java |
private JsiiObject createNative(final String fqn) {
try {
Class<?> klass = resolveJavaClass(fqn);
if (klass.isInterface() || Modifier.isAbstract(klass.getModifiers())) {
// "$" is used to represent inner classes in Java
klass = Class.forName(klass.getCanon... | java |
public void processAllPendingCallbacks() {
while (true) {
List<Callback> callbacks = this.getClient().pendingCallbacks();
if (callbacks.size() == 0) {
break;
}
callbacks.forEach(this::processCallback);
}
} | java |
private JsonNode invokeCallbackGet(final GetRequest req) {
Object obj = this.getObject(req.getObjref());
String methodName = javaScriptPropertyToJavaPropertyName("get", req.getProperty());
try {
Method getter = obj.getClass().getMethod(methodName);
return JsiiObjectMapper... | java |
private JsonNode invokeCallbackSet(final SetRequest req) {
final Object obj = this.getObject(req.getObjref());
String setterMethodName = javaScriptPropertyToJavaPropertyName("set", req.getProperty());
Method setter = null;
for (Method method: obj.getClass().getMethods()) {
i... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.