_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q23300
MiniTemplatorParser.beginMainBlock
train
private void beginMainBlock() { int blockNo = registerBlock(null); // =0 BlockTabRec btr = blockTab[blockNo]; btr.tPosBegin = 0; btr.tPosContentsBegin = 0; openBlocksTab[currentNestingLevel] = blockNo; currentNestingLevel++; }
java
{ "resource": "" }
q23301
MiniTemplatorParser.endMainBlock
train
private void endMainBlock() { BlockTabRec btr = blockTab[0]; btr.tPosContentsEnd = templateText.length(); btr.tPosEnd = templateText.length(); btr.definitionIsOpen = false; currentNestingLevel--; }
java
{ "resource": "" }
q23302
MiniTemplatorParser.processTemplateCommand
train
private boolean processTemplateCommand(String cmdLine, int cmdTPosBegin, int cmdTPosEnd) throws MiniTemplator.TemplateSyntaxException { int p0 = skipBlanks(cmdLine, 0); if (p0 >= cmdLine.length()) { return false; } int p = skipNonBlanks(cmdLine, p0); ...
java
{ "resource": "" }
q23303
MiniTemplatorParser.processShortFormTemplateCommand
train
private boolean processShortFormTemplateCommand(String cmdLine, int cmdTPosBegin, int cmdTPosEnd) throws MiniTemplator.TemplateSyntaxException { int p0 = skipBlanks(cmdLine, 0); if (p0 >= cmdLine.length()) { return false; } int p = p0; char cmd1 = c...
java
{ "resource": "" }
q23304
MiniTemplatorParser.registerBlock
train
private int registerBlock(String blockName) { int blockNo = blockTabCnt++; if (blockTabCnt > blockTab.length) { blockTab = (BlockTabRec[]) resizeArray(blockTab, 2 * blockTabCnt); } BlockTabRec btr = new BlockTabRec(); blockTab[blockNo] = btr; btr.blockN...
java
{ "resource": "" }
q23305
MiniTemplatorParser.excludeTemplateRange
train
private void excludeTemplateRange(int tPosBegin, int tPosEnd) { if (blockTabCnt > 0) { // Check whether we can extend the previous block. BlockTabRec btr = blockTab[blockTabCnt - 1]; if (btr.dummy && btr.tPosEnd == tPosBegin) { btr.tPosContentsEnd = tPosE...
java
{ "resource": "" }
q23306
MiniTemplatorParser.checkBlockDefinitionsComplete
train
private void checkBlockDefinitionsComplete() throws MiniTemplator.TemplateSyntaxException { for (int blockNo = 0; blockNo < blockTabCnt; blockNo++) { BlockTabRec btr = blockTab[blockNo]; if (btr.definitionIsOpen) { throw new MiniTemplator.TemplateSyntaxException( ...
java
{ "resource": "" }
q23307
MiniTemplatorParser.conditionalExclude
train
private boolean conditionalExclude(int tPosBegin, int tPosEnd) { if (isCondEnabled(condLevel)) { return false; } excludeTemplateRange(tPosBegin, tPosEnd); return true; }
java
{ "resource": "" }
q23308
MiniTemplatorParser.evaluateConditionFlags
train
private boolean evaluateConditionFlags(String flags) { int p = 0; while (true) { p = skipBlanks(flags, p); if (p >= flags.length()) { break; } boolean complement = false; if (flags.charAt(p) == '!') { co...
java
{ "resource": "" }
q23309
MiniTemplatorParser.associateVariablesWithBlocks
train
private void associateVariablesWithBlocks() { int varRefNo = 0; int activeBlockNo = 0; int nextBlockNo = 1; while (varRefNo < varRefTabCnt) { VarRefTabRec vrtr = varRefTab[varRefNo]; int varRefTPos = vrtr.tPosBegin; int varNo = vrtr.varNo; ...
java
{ "resource": "" }
q23310
MiniTemplatorParser.registerVariable
train
private int registerVariable(String varName) { int varNo = varTabCnt++; if (varTabCnt > varTab.length) { varTab = (String[]) resizeArray(varTab, 2 * varTabCnt); } varTab[varNo] = varName; varNameToNoMap.put(varName.toUpperCase(), new Integer(varNo)); re...
java
{ "resource": "" }
q23311
MiniTemplatorParser.lookupVariableName
train
public int lookupVariableName(String varName) { Integer varNoWrapper = varNameToNoMap.get(varName.toUpperCase()); if (varNoWrapper == null) { return -1; } int varNo = varNoWrapper.intValue(); return varNo; }
java
{ "resource": "" }
q23312
MiniTemplatorParser.lookupBlockName
train
public int lookupBlockName(String blockName) { Integer blockNoWrapper = blockNameToNoMap.get(blockName.toUpperCase()); if (blockNoWrapper == null) { return -1; } int blockNo = blockNoWrapper.intValue(); return blockNo; }
java
{ "resource": "" }
q23313
TemplateCodeGenerator.initEncodeMethodTemplateVariable
train
protected void initEncodeMethodTemplateVariable() { Set<Integer> orders = new HashSet<Integer>(); // encode method for (FieldInfo field : fields) { boolean isList = field.isList(); // check type if (!isList) { checkType(field.getFieldT...
java
{ "resource": "" }
q23314
CodedConstant.getWriteValueToField
train
public static String getWriteValueToField(FieldType type, String express, boolean isList) { if ((type == FieldType.STRING || type == FieldType.BYTES) && !isList) { String method = "copyFromUtf8"; if (type == FieldType.BYTES) { method = "copyFrom"; } ...
java
{ "resource": "" }
q23315
CodedConstant.getRequiredCheck
train
public static String getRequiredCheck(int order, Field field) { String fieldName = getFieldName(order); String code = "if (" + fieldName + "== null) {\n"; code += "throw new UninitializedMessageException(CodedConstant.asList(\"" + field.getName() + "\"))" + ClassCode.JAVA_LINE_BR...
java
{ "resource": "" }
q23316
CodedConstant.getEnumName
train
public static String getEnumName(Enum[] e, int value) { if (e != null) { int toCompareValue; for (Enum en : e) { if (en instanceof EnumReadable) { toCompareValue = ((EnumReadable) en).value(); } else { toCompareValue...
java
{ "resource": "" }
q23317
CodedConstant.getEnumValue
train
public static <T extends Enum<T>> T getEnumValue(Class<T> enumType, String name) { if (StringUtils.isEmpty(name)) { return null; } try { T v = Enum.valueOf(enumType, name); return v; } catch (IllegalArgumentException e) { ...
java
{ "resource": "" }
q23318
CodedConstant.convertList
train
private static List<Integer> convertList(List<String> list) { if (list == null) { return null; } List<Integer> ret = new ArrayList<Integer>(list.size()); for (String v : list) { ret.add(StringUtils.toInt(v)); } return ret; }
java
{ "resource": "" }
q23319
JprotobufPreCompileMain.isStartWith
train
private static boolean isStartWith(String testString, String[] targetStrings) { for (String s : targetStrings) { if (testString.startsWith(s)) { return true; } } return false; }
java
{ "resource": "" }
q23320
JprotobufPreCompileMain.getByClass
train
private static Class getByClass(String name) { try { return Thread.currentThread().getContextClassLoader().loadClass(name); } catch (Throwable e) { } return null; }
java
{ "resource": "" }
q23321
MapEntryLite.newDefaultInstance
train
public static <K, V> MapEntryLite<K, V> newDefaultInstance(WireFormat.FieldType keyType, K defaultKey, WireFormat.FieldType valueType, V defaultValue) { return new MapEntryLite<K, V>(keyType, defaultKey, valueType, defaultValue); }
java
{ "resource": "" }
q23322
MapEntryLite.writeTo
train
static <K, V> void writeTo(CodedOutputStream output, Metadata<K, V> metadata, K key, V value) throws IOException { CodedConstant.writeElement(output, metadata.keyType, KEY_FIELD_NUMBER, key); CodedConstant.writeElement(output, metadata.valueType, VALUE_FIELD_NUMBER, value); }
java
{ "resource": "" }
q23323
MapEntryLite.computeSerializedSize
train
static <K, V> int computeSerializedSize(Metadata<K, V> metadata, K key, V value) { return CodedConstant.computeElementSize(metadata.keyType, KEY_FIELD_NUMBER, key) + CodedConstant.computeElementSize(metadata.valueType, VALUE_FIELD_NUMBER, value); }
java
{ "resource": "" }
q23324
MapEntryLite.parseField
train
@SuppressWarnings("unchecked") static <T> T parseField(CodedInputStream input, ExtensionRegistryLite extensionRegistry, WireFormat.FieldType type, T value) throws IOException { switch (type) { case MESSAGE: int length = input.readRawVarint32(); final i...
java
{ "resource": "" }
q23325
MapEntryLite.parseEntry
train
static <K, V> Map.Entry<K, V> parseEntry(CodedInputStream input, Metadata<K, V> metadata, ExtensionRegistryLite extensionRegistry) throws IOException { K key = metadata.defaultKey; V value = metadata.defaultValue; while (true) { int tag = input.readTag(); if (...
java
{ "resource": "" }
q23326
IDLProxyObject.newInstnace
train
public IDLProxyObject newInstnace() { try { Object object = cls.newInstance(); return new IDLProxyObject(codec, object, cls); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
java
{ "resource": "" }
q23327
IDLProxyObject.doSetFieldValue
train
private IDLProxyObject doSetFieldValue(String fullField, String field, Object value, Object object, boolean useCache, Map<String, ReflectInfo> cachedFields) { Field f; // check cache if (useCache) { ReflectInfo info = cachedFields.get(fullField); if (inf...
java
{ "resource": "" }
q23328
PreCompileMojo.setSystemProperties
train
private void setSystemProperties() { if ( systemProperties != null ) { originalSystemProperties = System.getProperties(); for ( Property systemProperty : systemProperties ) { String value = systemProperty.getValue(); System.setPrope...
java
{ "resource": "" }
q23329
PreCompileMojo.getExecutablePomArtifact
train
private Artifact getExecutablePomArtifact( Artifact executableArtifact ) { return this.artifactFactory.createBuildArtifact( executableArtifact.getGroupId(), executableArtifact.getArtifactId(), e...
java
{ "resource": "" }
q23330
PreCompileMojo.waitFor
train
private void waitFor( long millis ) { Object lock = new Object(); synchronized ( lock ) { try { lock.wait( millis ); } catch ( InterruptedException e ) { Thread.currentThread().interrupt(); // good pr...
java
{ "resource": "" }
q23331
ProtobufIDLProxy.createMessageClass
train
private static List<Class<?>> createMessageClass(ProtoFile protoFile, boolean multi, boolean debug, boolean generateSouceOnly, File sourceOutputDir, List<CodeDependent> cds, Set<String> compiledClass, Set<String> enumNames, Set<String> packages, Map<String, String> mappedUniName, boolean isUniNa...
java
{ "resource": "" }
q23332
ProtobufIDLProxy.doCreate
train
private static Map<String, IDLProxyObject> doCreate(ProtoFile protoFile, boolean multi, boolean debug, File path, boolean generateSouceOnly, File sourceOutputDir, List<CodeDependent> cds, Map<String, String> uniMappedName, boolean isUniName) throws IOException { return doCreatePro(Arrays...
java
{ "resource": "" }
q23333
ProtobufIDLProxy.getPackages
train
private static Set<String> getPackages(List<CodeDependent> cds) { Set<String> ret = new HashSet<String>(); if (cds == null) { return ret; } for (CodeDependent cd : cds) { ret.add(cd.pkg); } return ret; }
java
{ "resource": "" }
q23334
ClassUtils.newInstance
train
public static Object newInstance(String name) { try { return forName(name).newInstance(); } catch (InstantiationException e) { throw new IllegalStateException(e.getMessage(), e); } catch (IllegalAccessException e) { throw new IllegalStateException(e.getMessage...
java
{ "resource": "" }
q23335
ClassUtils.doFormName
train
public static Class<?> doFormName(String className) throws ClassNotFoundException { if ("boolean".equals(className)) return boolean.class; if ("byte".equals(className)) return byte.class; if ("char".equals(className)) return char.class; if ("short".equ...
java
{ "resource": "" }
q23336
ClassUtils.getBoxedClass
train
public static Class<?> getBoxedClass(Class<?> type) { if (type == boolean.class) { return Boolean.class; } else if (type == char.class) { return Character.class; } else if (type == byte.class) { return Byte.class; } else if (type == short.class) { ...
java
{ "resource": "" }
q23337
ClassHelper.hasDefaultConstructor
train
public static boolean hasDefaultConstructor(Class<?> cls) { if (cls == null) { return false; } try { cls.getConstructor(new Class<?>[0]); } catch (NoSuchMethodException e2) { return false; } catch (SecurityException e2) { throw new ...
java
{ "resource": "" }
q23338
AbstractCodeGenerator.getMismatchTypeErroMessage
train
private String getMismatchTypeErroMessage(FieldType type, Field field) { return "Type mismatch. @Protobuf required type '" + type.getJavaType() + "' but field type is '" + field.getType().getSimpleName() + "' of field name '" + field.getName() + "' on class " + field.getDeclar...
java
{ "resource": "" }
q23339
ProtobufProxyUtils.fetchFieldInfos
train
public static List<FieldInfo> fetchFieldInfos(Class cls, boolean ignoreNoAnnotation) { // if set ProtobufClass annotation Annotation annotation = cls.getAnnotation(ProtobufClass.class); Annotation zipZap = cls.getAnnotation(EnableZigZap.class); boolean isZipZap = false; if...
java
{ "resource": "" }
q23340
ProtobufProxyUtils.isObjectType
train
public static boolean isObjectType(Class<?> cls) { FieldType fieldType = TYPE_MAPPING.get(cls); if (fieldType != null) { return false; } return true; }
java
{ "resource": "" }
q23341
ProtobufProxyUtils.processProtobufType
train
public static String processProtobufType(Class<?> cls) { FieldType fieldType = TYPE_MAPPING.get(cls); if (fieldType != null) { return fieldType.getType(); } return cls.getSimpleName(); }
java
{ "resource": "" }
q23342
CodedConstant.getFiledType
train
public static String getFiledType(FieldType type, boolean isList) { if ((type == FieldType.STRING || type == FieldType.BYTES) && !isList) { return "com.google.protobuf.ByteString"; } // add null check String defineType = type.getJavaType(); if (isList)...
java
{ "resource": "" }
q23343
CodedConstant.getMappedTypeSize
train
public static String getMappedTypeSize(FieldInfo field, int order, FieldType type, boolean isList, boolean isMap, boolean debug, File path) { String fieldName = getFieldName(order); String spath = "null"; if (path != null) { spath = "new java.io.File(\"" + path.get...
java
{ "resource": "" }
q23344
CodedConstant.getMapFieldGenericParameterString
train
public static String getMapFieldGenericParameterString(FieldInfo field) { FieldType fieldType = ProtobufProxyUtils.TYPE_MAPPING.get(field.getGenericKeyType()); String keyClass; String defaultKeyValue; if (fieldType == null) { // may be object or enum if (Enu...
java
{ "resource": "" }
q23345
CodedConstant.computeMapSize
train
public static <K, V> int computeMapSize(int order, Map<K, V> map, com.google.protobuf.WireFormat.FieldType keyType, K defaultKey, com.google.protobuf.WireFormat.FieldType valueType, V defalutValue) { int size = 0; for (java.util.Map.Entry<K, V> entry : map.entrySet()) { com.b...
java
{ "resource": "" }
q23346
CodedConstant.putMapValue
train
public static <K, V> void putMapValue(CodedInputStream input, Map<K, V> map, com.google.protobuf.WireFormat.FieldType keyType, K defaultKey, com.google.protobuf.WireFormat.FieldType valueType, V defalutValue) throws IOException { putMapValue(input, map, keyType, defaultKey, valueType,...
java
{ "resource": "" }
q23347
CodedConstant.computeObjectSizeNoTag
train
public static int computeObjectSizeNoTag(Object o) { int size = 0; if (o == null) { return size; } Class cls = o.getClass(); Codec target = ProtobufProxy.create(cls); try { size = target.size(o); size = size + CodedOutputStre...
java
{ "resource": "" }
q23348
CodedConstant.writeToList
train
public static void writeToList(CodedOutputStream out, int order, FieldType type, List list) throws IOException { writeToList(out, order, type, list, false); }
java
{ "resource": "" }
q23349
CodedConstant.writeObject
train
public static void writeObject(CodedOutputStream out, int order, FieldType type, Object o, boolean list) throws IOException { writeObject(out, order, type, o, list, true); }
java
{ "resource": "" }
q23350
CodedConstant.getEnumValue
train
public static int getEnumValue(Enum en) { if (en != null) { int toCompareValue; if (en instanceof EnumReadable) { toCompareValue = ((EnumReadable) en).value(); } else { toCompareValue = en.ordinal(); } return toC...
java
{ "resource": "" }
q23351
CodedConstant.readPrimitiveField
train
public static Object readPrimitiveField(CodedInputStream input, final WireFormat.FieldType type, boolean checkUtf8) throws IOException { switch (type) { case DOUBLE: return input.readDouble(); case FLOAT: return input.readFloat(); ...
java
{ "resource": "" }
q23352
CodedConstant.writeElement
train
public static void writeElement(final CodedOutputStream output, final WireFormat.FieldType type, final int number, final Object value) throws IOException { // Special case for groups, which need a start and end tag; other fields // can just use writeTag() and writeFieldNoTag(). i...
java
{ "resource": "" }
q23353
CodedConstant.getWireFormatForFieldType
train
static int getWireFormatForFieldType(final WireFormat.FieldType type, boolean isPacked) { if (isPacked) { return WireFormat.WIRETYPE_LENGTH_DELIMITED; } else { return type.getWireType(); } }
java
{ "resource": "" }
q23354
CodedConstant.computeElementSizeNoTag
train
public static int computeElementSizeNoTag(final WireFormat.FieldType type, final Object value) { switch (type) { // Note: Minor violation of 80-char limit rule here because this would // actually be harder to read if we wrapped the lines. case DOUBLE: ret...
java
{ "resource": "" }
q23355
CodedConstant.getMapKVMessageElements
train
private static MessageElement getMapKVMessageElements(String name, MapType mapType) { MessageElement.Builder ret = MessageElement.builder(); ret.name(name); DataType keyType = mapType.keyType(); Builder fieldBuilder = FieldElement.builder().name("key").tag(1); fieldBuilder...
java
{ "resource": "" }
q23356
IDLProxyObject.doGetFieldValue
train
private Object doGetFieldValue(String fullField, String field, Object object, boolean useCache, Map<String, ReflectInfo> cachedFields) { // check cache Field f; if (useCache) { ReflectInfo info = cachedFields.get(fullField); if (info != null) { ...
java
{ "resource": "" }
q23357
ProtobufProxy.isDebugEnabled
train
public static boolean isDebugEnabled() { String debugEnv = System.getenv(DEBUG_CONTROL); if (debugEnv != null && Boolean.parseBoolean(debugEnv)) { return true; } Boolean debug = DEBUG_CONTROLLER.get(); if (debug == null) { debug = false; // set de...
java
{ "resource": "" }
q23358
ProtobufProxy.getCodeGenerator
train
private static ICodeGenerator getCodeGenerator(Class cls) { // check if has default constructor if (!cls.isMemberClass()) { try { cls.getConstructor(new Class<?>[0]); } catch (NoSuchMethodException e2) { throw new IllegalArgumentException( ...
java
{ "resource": "" }
q23359
ClassHelper.getClassLoader
train
public static ClassLoader getClassLoader(Class<?> cls) { ClassLoader cl = null; try { cl = Thread.currentThread().getContextClassLoader(); } catch (Throwable ex) { // Cannot access thread context ClassLoader - falling back to system // class loader... ...
java
{ "resource": "" }
q23360
MapEntry.newDefaultInstance
train
public static <K, V> MapEntry<K, V> newDefaultInstance(Descriptor descriptor, WireFormat.FieldType keyType, K defaultKey, WireFormat.FieldType valueType, V defaultValue) { return new MapEntry<K, V>(descriptor, keyType, defaultKey, valueType, defaultValue); }
java
{ "resource": "" }
q23361
MapEntry.checkFieldDescriptor
train
private void checkFieldDescriptor(FieldDescriptor field) { if (field.getContainingType() != metadata.descriptor) { throw new RuntimeException("Wrong FieldDescriptor \"" + field.getFullName() + "\" used in message \"" + metadata.descriptor.getFullName()); } }
java
{ "resource": "" }
q23362
MapField.emptyMapField
train
public static <K, V> MapField<K, V> emptyMapField(MapEntry<K, V> defaultEntry) { return new MapField<K, V>(defaultEntry, StorageMode.MAP, Collections.<K, V> emptyMap(), null); }
java
{ "resource": "" }
q23363
MapField.newMapField
train
public static <K, V> MapField<K, V> newMapField(MapEntry<K, V> defaultEntry) { return new MapField<K, V>(defaultEntry, StorageMode.MAP, new HashMap<K, V>(), null); }
java
{ "resource": "" }
q23364
MapField.getMap
train
public Map<K, V> getMap() { if (mode == StorageMode.LIST) { synchronized (this) { if (mode == StorageMode.LIST) { mapData = convertListToMap(listData); mode = StorageMode.BOTH; } } } return Collection...
java
{ "resource": "" }
q23365
MapField.getMutableMap
train
public Map<K, V> getMutableMap() { if (mode != StorageMode.MAP) { if (mode == StorageMode.LIST) { mapData = convertListToMap(listData); } listData = null; mode = StorageMode.MAP; } return mapData; }
java
{ "resource": "" }
q23366
MapField.copy
train
public MapField<K, V> copy() { return new MapField<K, V>(converter, StorageMode.MAP, MapFieldLite.copy(getMap()), null); }
java
{ "resource": "" }
q23367
MapField.getList
train
List<Message> getList() { if (mode == StorageMode.MAP) { synchronized (this) { if (mode == StorageMode.MAP) { listData = convertMapToList(mapData); mode = StorageMode.BOTH; } } } return Collections.un...
java
{ "resource": "" }
q23368
MapField.getMutableList
train
List<Message> getMutableList() { if (mode != StorageMode.LIST) { if (mode == StorageMode.MAP) { listData = convertMapToList(mapData); } mapData = null; mode = StorageMode.LIST; } return listData; }
java
{ "resource": "" }
q23369
CodeGenerator.genImportCode
train
private void genImportCode(StringBuilder code) { code.append("import com.google.protobuf.*").append(JAVA_LINE_BREAK); code.append("import java.io.IOException").append(JAVA_LINE_BREAK); code.append("import com.baidu.bjf.remoting.protobuf.utils.*").append(JAVA_LINE_BREAK); code.append(...
java
{ "resource": "" }
q23370
CodeTemplate.descriptorMethodSource
train
public static String descriptorMethodSource(Class cls) { String descriptorClsName = ClassHelper.getInternalName(Descriptor.class.getCanonicalName()); String code = "if (this.descriptor != null) {" + ClassCode.LINE_BREAK + "return this.descriptor;" + ClassCode.LI...
java
{ "resource": "" }
q23371
ProtobufIDLProxy.createEnumClasses
train
private static List<Class<?>> createEnumClasses(Map<String, EnumElement> enumTypes, Map<String, String> packageMapping, boolean generateSouceOnly, File sourceOutputDir, Set<String> compiledClass, Map<String, String> mappedUniName, boolean isUniName) { List<Class<?>> ret = new ArrayL...
java
{ "resource": "" }
q23372
ProtobufIDLProxy.getTypeName
train
private static String getTypeName(FieldElement field) { DataType type = field.type(); return type.toString(); }
java
{ "resource": "" }
q23373
MapFieldLite.emptyMapField
train
@SuppressWarnings({ "unchecked", "cast" }) public static <K, V> MapFieldLite<K, V> emptyMapField() { return (MapFieldLite<K, V>) EMPTY_MAP_FIELD; }
java
{ "resource": "" }
q23374
MapFieldLite.mergeFrom
train
public void mergeFrom(MapFieldLite<K, V> other) { ensureMutable(); if (!other.isEmpty()) { putAll(other); } }
java
{ "resource": "" }
q23375
CodeGenerator.genImportCode
train
private void genImportCode(ClassCode code) { code.importClass("java.util.*"); code.importClass("java.io.IOException"); code.importClass("java.lang.reflect.*"); code.importClass("com.baidu.bjf.remoting.protobuf.code.*"); code.importClass("com.baidu.bjf.remoting.protobuf.utils.*");...
java
{ "resource": "" }
q23376
CodeGenerator.getDecodeMethodCode
train
private MethodCode getDecodeMethodCode() { MethodCode mc = new MethodCode(); mc.setName("decode"); mc.setScope(ClassCode.SCOPE_PUBLIC); mc.setReturnType(ClassHelper.getInternalName(cls.getCanonicalName())); mc.addParameter("byte[]", "bb"); mc.addException("IOException"); ...
java
{ "resource": "" }
q23377
CodeGenerator.getGetDescriptorMethodCode
train
private MethodCode getGetDescriptorMethodCode() { String descriptorClsName = ClassHelper.getInternalName(Descriptor.class.getCanonicalName()); MethodCode mc = new MethodCode(); mc.setName("getDescriptor"); mc.setReturnType(descriptorClsName); mc.setScope(ClassCode.SCOPE_PUBLIC);...
java
{ "resource": "" }
q23378
CodeGenerator.getWriteToMethodCode
train
private MethodCode getWriteToMethodCode() { MethodCode mc = new MethodCode(); mc.setName("writeTo"); mc.setReturnType("void"); mc.setScope(ClassCode.SCOPE_PUBLIC); mc.addParameter(ClassHelper.getInternalName(cls.getCanonicalName()), "t"); mc.addParameter("CodedOutputStrea...
java
{ "resource": "" }
q23379
CodeGenerator.getSizeMethodCode
train
private MethodCode getSizeMethodCode() { MethodCode mc = new MethodCode(); mc.setName("size"); mc.setScope(ClassCode.SCOPE_PUBLIC); mc.setReturnType("int"); mc.addParameter(ClassHelper.getInternalName(cls.getCanonicalName()), "t"); mc.addException("IOException"); ...
java
{ "resource": "" }
q23380
CodeGenerator.getAccessByField
train
protected String getAccessByField(String target, Field field, Class<?> cls) { if (field.getModifiers() == Modifier.PUBLIC) { return target + ClassHelper.PACKAGE_SEPARATOR + field.getName(); } // check if has getter method String getter; if ("boolean".equalsIgnoreCase(...
java
{ "resource": "" }
q23381
CodePrinter.printCode
train
public static void printCode(String code, String desc) { System.out.println("--------------------------" + desc + " begin--------------------------"); System.out.println(code); System.out.println("--------------------------" + desc + " end--------------------------"); }
java
{ "resource": "" }
q23382
P12Util.getFirstPrivateKeyEntryFromP12InputStream
train
public static PrivateKeyEntry getFirstPrivateKeyEntryFromP12InputStream(final InputStream p12InputStream, final String password) throws KeyStoreException, IOException { Objects.requireNonNull(password, "Password may be blank, but must not be null."); final KeyStore keyStore = KeyStore.getInstance("PKCS...
java
{ "resource": "" }
q23383
BaseHttp2Server.start
train
public Future<Void> start(final int port) { final ChannelFuture channelFuture = this.bootstrap.bind(port); this.allChannels.add(channelFuture.channel()); return channelFuture; }
java
{ "resource": "" }
q23384
ServerChannelClassUtil.getServerSocketChannelClass
train
@SuppressWarnings("unchecked") static Class<? extends ServerChannel> getServerSocketChannelClass(final EventLoopGroup eventLoopGroup) { Objects.requireNonNull(eventLoopGroup); final String serverSocketChannelClassName = SERVER_SOCKET_CHANNEL_CLASSES.get(eventLoopGroup.getClass().getName()); ...
java
{ "resource": "" }
q23385
ApnsChannelFactory.create
train
@Override public Future<Channel> create(final Promise<Channel> channelReadyPromise) { final long delay = this.currentDelaySeconds.get(); channelReadyPromise.addListener(new GenericFutureListener<Future<Channel>>() { @Override public void operationComplete(final Future<Chann...
java
{ "resource": "" }
q23386
ApnsChannelFactory.destroy
train
@Override public Future<Void> destroy(final Channel channel, final Promise<Void> promise) { channel.close().addListener(new PromiseNotifier<>(promise)); return promise; }
java
{ "resource": "" }
q23387
AuthenticationToken.verifySignature
train
public boolean verifySignature(final ApnsVerificationKey verificationKey) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException { if (!this.header.getKeyId().equals(verificationKey.getKeyId())) { return false; } if (!this.claims.getIssuer().equals(verificationKey....
java
{ "resource": "" }
q23388
MicrometerApnsClientMetricsListener.handleWriteFailure
train
@Override public void handleWriteFailure(final ApnsClient apnsClient, final long notificationId) { this.notificationStartTimes.remove(notificationId); this.writeFailures.increment(); }
java
{ "resource": "" }
q23389
ApnsVerificationKey.loadFromInputStream
train
public static ApnsVerificationKey loadFromInputStream(final InputStream inputStream, final String teamId, final String keyId) throws IOException, NoSuchAlgorithmException, InvalidKeyException { final ECPublicKey verificationKey; { final String base64EncodedPublicKey; { ...
java
{ "resource": "" }
q23390
ApnsSigningKey.loadFromInputStream
train
public static ApnsSigningKey loadFromInputStream(final InputStream inputStream, final String teamId, final String keyId) throws IOException, NoSuchAlgorithmException, InvalidKeyException { final ECPrivateKey signingKey; { final String base64EncodedPrivateKey; { fi...
java
{ "resource": "" }
q23391
AcceptAllPushNotificationHandlerFactory.buildHandler
train
@Override public PushNotificationHandler buildHandler(final SSLSession sslSession) { return new PushNotificationHandler() { @Override public void handlePushNotification(final Http2Headers headers, final ByteBuf payload) { // Accept everything unconditionally! ...
java
{ "resource": "" }
q23392
ApnsChannelPool.release
train
void release(final Channel channel) { if (this.executor.inEventLoop()) { this.releaseWithinEventExecutor(channel); } else { this.executor.submit(new Runnable() { @Override public void run() { ApnsChannelPool.this.releaseWithinEv...
java
{ "resource": "" }
q23393
ApnsChannelPool.close
train
public Future<Void> close() { return this.allChannels.close().addListener(new GenericFutureListener<Future<Void>>() { @Override public void operationComplete(final Future<Void> future) throws Exception { ApnsChannelPool.this.isClosed = true; if (ApnsChann...
java
{ "resource": "" }
q23394
BaseHttp2ServerBuilder.build
train
public T build() throws SSLException { final SslContext sslContext; { final SslProvider sslProvider; if (OpenSsl.isAvailable()) { log.info("Native SSL provider is available; will use native provider."); sslProvider = SslProvider.OPENSSL; ...
java
{ "resource": "" }
q23395
ClientChannelClassUtil.getSocketChannelClass
train
static Class<? extends SocketChannel> getSocketChannelClass(final EventLoopGroup eventLoopGroup) { Objects.requireNonNull(eventLoopGroup); final String socketChannelClassName = SOCKET_CHANNEL_CLASSES.get(eventLoopGroup.getClass().getName()); if (socketChannelClassName == null) { th...
java
{ "resource": "" }
q23396
ClientChannelClassUtil.getDatagramChannelClass
train
static Class<? extends DatagramChannel> getDatagramChannelClass(final EventLoopGroup eventLoopGroup) { Objects.requireNonNull(eventLoopGroup); final String datagramChannelClassName = DATAGRAM_CHANNEL_CLASSES.get(eventLoopGroup.getClass().getName()); if (datagramChannelClassName == null) { ...
java
{ "resource": "" }
q23397
AbstractScreen.setCursorPosition
train
@Override public void setCursorPosition(TerminalPosition position) { if(position == null) { //Skip any validation checks if we just want to hide the cursor this.cursorPosition = null; return; } if(position.getColumn() < 0) { position = position...
java
{ "resource": "" }
q23398
AbstractScreen.scrollLines
train
@Override public void scrollLines(int firstLine, int lastLine, int distance) { getBackBuffer().scrollLines(firstLine, lastLine, distance); }
java
{ "resource": "" }
q23399
StreamBasedTerminal.waitForCursorPositionReport
train
synchronized TerminalPosition waitForCursorPositionReport() throws IOException { long startTime = System.currentTimeMillis(); TerminalPosition cursorPosition = lastReportedCursorPosition; while(cursorPosition == null) { if(System.currentTimeMillis() - startTime > 5000) { ...
java
{ "resource": "" }