code
stringlengths
73
34.1k
label
stringclasses
1 value
public void indexDocument(final ODocument iDocument) { modificationLock.requestModificationLock(); try { Object fieldValue; for (final String fieldName : iDocument.fieldNames()) { fieldValue = iDocument.field(fieldName); put(fieldValue, iDocument); } acquire...
java
@Override public OIndexFullText put(final Object iKey, final OIdentifiable iSingleValue) { if (iKey == null) return this; modificationLock.requestModificationLock(); try { final List<String> words = splitIntoWords(iKey.toString()); // FOREACH WORD CREATE THE LINK TO THE CURR...
java
@Override public boolean remove(final Object iKey, final OIdentifiable value) { modificationLock.requestModificationLock(); try { final List<String> words = splitIntoWords(iKey.toString()); boolean removed = false; for (final String word : words) { acquireExclusiveLock()...
java
public List<ORecordOperation> getRecordEntriesByClass(final String iClassName) { final List<ORecordOperation> result = new ArrayList<ORecordOperation>(); if (iClassName == null || iClassName.length() == 0) // RETURN ALL THE RECORDS for (ORecordOperation entry : recordEntries.values()) { ...
java
public List<ORecordOperation> getRecordEntriesByClusterIds(final int[] iIds) { final List<ORecordOperation> result = new ArrayList<ORecordOperation>(); if (iIds == null) // RETURN ALL THE RECORDS for (ORecordOperation entry : recordEntries.values()) { result.add(entry); } ...
java
protected static int getValueByBinStr(String binaryString, boolean signed) { Integer value = Integer.parseInt(binaryString, 2); if (signed && binaryString.charAt(0) == '1') { char[] invert = new char[binaryString.length()]; Arrays.fill(invert, '1'); value ^= Integer.parseInt(new String(invert), 2); val...
java
@VisibleForTesting static byte[] ascii8To6bitBin(byte[] toDecBytes) { byte[] convertedBytes = new byte[toDecBytes.length]; int sum = 0; int _6bitBin = 0; for (int i = 0; i < toDecBytes.length; i++) { sum = 0; _6bitBin = 0; if (toDecBytes[i] < 48) { throw new AisParseException(AisParseException....
java
private static String getDecodedStr(byte[] decBytes) { // prepare StringBuilder with capacity being the smallest power of 2 // greater than decBytes.length*6 int n = decBytes.length * 6; int capacity = leastPowerOf2GreaterThanOrEqualTo(n); StringBuilder decStr = new StringBuilder(capacity); for (int i = 0...
java
protected static String getAsciiStringFrom6BitStr(String str) { StringBuilder txt = new StringBuilder(); for (int i = 0; i < str.length(); i = i + 6) { byte _byte = (byte) Integer.parseInt(str.substring(i, i + 6), 2); _byte = convert6BitCharToStandardAscii(_byte); char convChar = (char) _byte; if (con...
java
@VisibleForTesting static byte convert6BitCharToStandardAscii(byte byteToConvert) { byte b = 0; if (byteToConvert < 32) { b = (byte) (byteToConvert + 64); } else if (byteToConvert < 63) { b = byteToConvert; } return b; }
java
public static void checkLatLong(double lat, double lon) { checkArgument(lon <= 181.0, "longitude out of range " + lon); checkArgument(lon > -180.0, "longitude out of range " + lon); checkArgument(lat <= 91.0, "latitude out of range " + lat); checkArgument(lat > -90.0, "latitude out of range " + lat); }
java
public static void checkMessageId(int messageId, AisMessageType... messageTypes) { boolean found = false; for (AisMessageType messageType : messageTypes) { if (messageType.getId() == messageId) found = true; } if (!found) { StringBuffer s = new StringBuffer(); for (AisMessageType messageType : mess...
java
public static OMMapManager getInstance() { if (instanceRef.get() == null) { synchronized (instanceRef) { if (instanceRef.compareAndSet(null, createInstance())) { instanceRef.get().init(); } } } return instanceRef.get(); }
java
public void addArrayIdentity(String array, String... identities) { arrayIdentities.put(array, new ArrayIdentityFields(identities)); }
java
public Difference<BaseType> compareNodes(BaseType node1, BaseType node2) throws InvalidArrayIdentity, DuplicateArrayIdentity { return compareNodes(new ArrayList<String>(), node1, new ArrayList<String>(), node2); }
java
public Difference<BaseType> compareObjects(List<String> field1, ObjectType node1, List<String> field2, ObjectType node2) throws InvalidArrayIdentity, DuplicateArrayIde...
java
public Difference<BaseType> compareArraysWithId(List<String> field1, ArrayType node1, List<String> field2, ArrayType node2, ...
java
@Deprecated public OPropertyImpl dropIndexes() { getDatabase().checkSecurity(ODatabaseSecurityResources.SCHEMA, ORole.PERMISSION_DELETE); final OIndexManager indexManager = getDatabase().getMetadata().getIndexManager(); final ArrayList<OIndex<?>> relatedIndexes = new ArrayList<OIndex<?>>(); f...
java
@Deprecated public OIndex<?> getIndex() { Set<OIndex<?>> indexes = owner.getInvolvedIndexes(name); if (indexes != null && !indexes.isEmpty()) return indexes.iterator().next(); return null; }
java
public OClass getLinkedClass() { if (linkedClass == null && linkedClassName != null) linkedClass = owner.owner.getClass(linkedClassName); return linkedClass; }
java
public void setTypeInternal(final OType iType) { getDatabase().checkSecurity(ODatabaseSecurityResources.SCHEMA, ORole.PERMISSION_UPDATE); if (iType == type) // NO CHANGES return; boolean ok = false; switch (type) { case LINKLIST: ok = iType == OType.LINKSET; break;...
java
@Override public void putAll(final Map<? extends K, ? extends V> map) { int mapSize = map.size(); if (size() == 0 && mapSize != 0 && map instanceof SortedMap) { Comparator<?> c = ((SortedMap<? extends K, ? extends V>) map).comparator(); if (c == comparator || (c != null && c.equals(comparator...
java
@Override public V remove(final Object key) { OMVRBTreeEntry<K, V> p = getEntry(key, PartialSearchMode.NONE); setLastSearchNode(null, null); if (p == null) return null; V oldValue = p.getValue(); deleteEntry(p); return oldValue; }
java
public static <K, V> OMVRBTreeEntry<K, V> next(final OMVRBTreeEntry<K, V> t) { if (t == null) return null; final OMVRBTreeEntry<K, V> succ; if (t.tree.pageIndex < t.getSize() - 1) { // ITERATE INSIDE THE NODE succ = t; t.tree.pageIndex++; } else { // GET THE NEXT...
java
public static <K, V> OMVRBTreeEntry<K, V> previous(final OMVRBTreeEntry<K, V> t) { if (t == null) return null; final int index = t.getTree().getPageIndex(); final OMVRBTreeEntry<K, V> prev; if (index <= 0) { prev = predecessor(t); if (prev != null) t.tree.pageIndex ...
java
OMVRBTreeEntry<K, V> deleteEntry(OMVRBTreeEntry<K, V> p) { setSizeDelta(-1); modCount++; if (pageIndex > -1) { // DELETE INSIDE THE NODE p.remove(); if (p.getSize() > 0) return p; } final OMVRBTreeEntry<K, V> next = successor(p); // DELETE THE ENTIRE NODE,...
java
protected OMVRBTreeEntry<K, V> removeNode(OMVRBTreeEntry<K, V> p) { modCount++; // If strictly internal, copy successor's element to p and then make p // point to successor. if (p.getLeft() != null && p.getRight() != null) { OMVRBTreeEntry<K, V> s = next(p); p.copyFrom(s); p = s...
java
void readOTreeSet(int iSize, ObjectInputStream s, V defaultVal) throws java.io.IOException, ClassNotFoundException { buildFromSorted(iSize, null, s, defaultVal); }
java
void addAllForOTreeSet(SortedSet<? extends K> set, V defaultVal) { try { buildFromSorted(set.size(), set.iterator(), null, defaultVal); } catch (java.io.IOException cannotHappen) { } catch (ClassNotFoundException cannotHappen) { } }
java
public static Observable<Fix> from(final File file, BinaryFixesFormat format) { Func0<InputStream> resourceFactory = new Func0<InputStream>() { @Override public InputStream call() { try { if (file.getName().endsWith(".gz")) re...
java
protected String parserOptionalWord(final boolean iUpperCase) { previousPos = currentPos; parserNextWord(iUpperCase); if (parserLastWord.length() == 0) return null; return parserLastWord.toString(); }
java
protected String parseOptionalWord(final boolean iUpperCase, final String... iWords) { parserNextWord(iUpperCase); if (iWords.length > 0) { if (parserLastWord.length() == 0) return null; boolean found = false; for (String w : iWords) { if (parserLastWord.toString().e...
java
protected String parserRequiredWord(final boolean iUpperCase, final String iCustomMessage, String iSeparators) { if (iSeparators == null) iSeparators = " =><(),\r\n"; parserNextWord(iUpperCase, iSeparators); if (parserLastWord.length() == 0) throwSyntaxErrorException(iCustomMessage); ...
java
protected void parserNextWord(final boolean iForceUpperCase, final String iSeparatorChars) { previousPos = currentPos; parserLastWord.setLength(0); parserSkipWhiteSpaces(); if (currentPos == -1) return; char stringBeginChar = ' '; final String text2Use = iForceUpperCase ? text...
java
public HandlerBuilder<ContextHandler> createRootContextHandler(String subPath) { ContextHandler contextHandler = new ContextHandler(); HandlerBuilder<ContextHandler> e = new HandlerBuilder<>(contextHandler); String usePath = contextPath + subPath; setPath(contextHandler, usePath); ...
java
public Optional<List<NmeaMessage>> add(NmeaMessage nmea) { // use compare-and-swap semantics instead of synchronizing to squeak a // bit more performance out of this. Contention is expected to be low so // this should help. while (true) { if (adding.compareAndSet(false, true)...
java
public static String getServiceName(MuleEventContext event) { // Mule 2.2 implementation // Service service = (event == null)? null : event.getService(); FlowConstruct service = (event == null)? null : event.getFlowConstruct(); String name = (service == null)? "" : service.getNam...
java
public static ImmutableEndpoint getImmutableEndpoint(MuleContext muleContext, String endpointName) throws IOException { ImmutableEndpoint endpoint = null; Object o = muleContext.getRegistry().lookupObject(endpointName); if (o instanceof ImmutableEndpoint) { // For Inbound and Outbound Endpoints endpoint = ...
java
@Override public OMVRBTreeEntryMemory<K, V> getNextInMemory() { OMVRBTreeEntryMemory<K, V> t = this; OMVRBTreeEntryMemory<K, V> p = null; if (t.right != null) { p = t.right; while (p.left != null) p = p.left; } else { p = t.parent; while (p != null && t == p.right) { t = p; ...
java
public V setValue(final V value) { V oldValue = this.getValue(); this.values[tree.pageIndex] = value; return oldValue; }
java
private void convertLink2Record(final int iIndex) { if (ridOnly || !autoConvertToRecord) // PRECONDITIONS return; final OIdentifiable o = super.get(iIndex); if (contentType == MULTIVALUE_CONTENT_TYPE.ALL_RECORDS && !o.getIdentity().isNew()) // ALL RECORDS AND THE OBJECT IS NOT NEW, DO NOTHING ...
java
private boolean convertRecord2Link(final int iIndex) { if (contentType == MULTIVALUE_CONTENT_TYPE.ALL_RIDS) // PRECONDITIONS return true; final Object o = super.get(iIndex); if (o != null) { if (o instanceof ORecord<?> && !((ORecord<?>) o).isDirty()) { marshalling = true; try { ...
java
public static String convertStreamToString(InputStream is, String charset) { if (is == null) return null; StringBuilder sb = new StringBuilder(); String line; long linecount = 0; long size = 0; try { // TODO: Can this be a performance killer if many many lines or is...
java
static Properties convertResourceBundleToProperties(ResourceBundle resource) { Properties properties = new Properties(); Enumeration<String> keys = resource.getKeys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); properties.put(key, resource.getStrin...
java
protected Map<Method, Object> getConsoleMethods() { // search for declared command collections final Iterator<OConsoleCommandCollection> ite = ServiceRegistry.lookupProviders(OConsoleCommandCollection.class); final Collection<Object> candidates = new ArrayList<Object>(); candidates.add(this); ...
java
static public List<String> listFilesInDirectory(MuleContext muleContext, String endpointName) { logger.info("List endpoint: {}", endpointName); FTPClient ftpClient = null; List<String> fileNames = new ArrayList<String>(); try { ftpClient = getFtpClient(muleContext, endpoin...
java
static public void recursiveDeleteDirectory(FTPClient ftpClient, String path) throws IOException { logger.info("Delete directory: {}", path); FTPFile[] ftpFiles = ftpClient.listFiles(path); logger.debug("Number of files that will be deleted: {}", ftpFiles.length); for (FTPFile ftpFile...
java
static public void recursiveCreateDirectory(FTPClient ftpClient, String path) throws IOException { logger.info("Create Directory: {}", path); int createDirectoryStatus = ftpClient.mkd(path); // makeDirectory... logger.debug("Create Directory Status: {}", createDirectoryStatus); if (createDirectoryStatus == ...
java
private void insertLinks(Theme theme) { if (theme != null) { for (CssLink link : theme.getLinks()) { this.getHead().appendChild(link.getLink()); } } }
java
private void removeCssLinks() { if (this.isInit) { return; } this.isInit = true; // Remove all existing link element NodeList<Element> links = this.getHead().getElementsByTagName(LinkElement.TAG); int size = links.getLength(); for (int i = 0; i < size; i++) { LinkElement elem = LinkElement.as(links....
java
protected HeadElement getHead() { if (this.head == null) { Element elt = Document.get().getElementsByTagName("head").getItem(0); assert elt != null : "The host HTML page does not have a <head> element" + " which is required by this injector"; this.head = HeadElement.as(elt); } return this.head; }
java
public static void reset() { deactivateLogging(); deactivateReporting(); defaultLogLevel = Constants.INFO; defaultReportLevel = Constants.INFO; detectWTFMethods(); logLevels.clear(); maxOfEntriesInReports = 25; enableLogEntryCollection = false; ent...
java
private static Integer getLogLevel(String tag) { Integer result = logLevels.get(tag); if (tag != null && result == null) { int index = tag.lastIndexOf("."); while (result == null && index > -1) { result = logLevels.get(tag.substring(0, index)); ind...
java
public static boolean report(String message, Throwable error) { boolean acc = true; for (Reporter reporter : reporters) { if (reportFactory != null && reporter instanceof EnhancedReporter) { Report report = reportFactory.create(context, message, error); acc = ...
java
private static synchronized void collectLogEntry(int level, String tag, final String message, final Throwable err) { if (!isReportable(level)) { return; } if (maxOfEntriesInReports > 0 && entries.size() == maxOfEntriesInReports) { entries.remo...
java
public void grant(final String iResource, final int iOperation) { final Byte current = rules.get(iResource); byte currentValue = current == null ? PERMISSION_NONE : current.byteValue(); currentValue |= (byte) iOperation; rules.put(iResource, currentValue); document.field("rules", rules); ...
java
public static String permissionToString(final int iPermission) { int permission = iPermission; final StringBuilder returnValue = new StringBuilder(); for (Entry<Integer, String> p : PERMISSION_BIT_NAMES.entrySet()) { if ((permission & p.getKey()) == p.getKey()) { if (returnValue.length() ...
java
public void start() { try { while (keepGoing) { try { // this is a blocking call so it hogs a thread final Socket socket = ss.accept(); final String socketName = socket.getInetAddress().getHostAddress() + ":" ...
java
protected static int getLevel(String level, int defaultLogLevel) { try { return Integer.parseInt(level); } catch (NumberFormatException e) { // Try to read the string. if ("VERBOSE".equalsIgnoreCase(level)) { return Constants.VERBOSE; } els...
java
public static String getCaller() { StackTraceElement[] stacks = Thread.currentThread().getStackTrace(); if (stacks != null) { for (int i = 0; i < stacks.length; i++) { String cn = stacks[i].getClassName(); if (cn != null && !Constants.CLASSNAME_TO_ESCAPE.conta...
java
protected static InputStream getConfigurationFileFromSDCard(String fileName) { File sdcard = Environment.getExternalStorageDirectory(); if (sdcard == null || !sdcard.exists() || !sdcard.canRead()) { return null; } String sdCardPath = sdcard.getAbsolutePath(); File p...
java
protected static InputStream getConfigurationFileFromAssets(Context context, String fileName) { if (context == null) { return null; } AssetManager assets = context.getAssets(); if (assets == null) { return null; } try { re...
java
public static String print(int priority, String tag, String msg, Throwable tr, boolean addTimestamp) { // Compute the letter for the given priority String p = "X"; // X => Unknown switch (priority) { case Constants.DEBUG: p = "D"; break; ca...
java
public int readLength() throws IOException { int length = 0; byte b = (byte) this.read(); // This is short form. The short form can be used if the number of // octets in the Value part is less than or // equal to 127, and can be used whether the Value part is primitive or // constructed. This form...
java
public AsnInputStream readSequenceStreamData(int length) throws AsnException, IOException { if (length == Tag.Indefinite_Length) { return this.readSequenceIndefinite(); } else { int startPos = this.pos; this.advance(length); return new AsnInputStream(this, startPos, length); } }
java
public byte[] readSequenceData(int length) throws AsnException, IOException { AsnInputStream ais = this.readSequenceStreamData(length); byte[] res = new byte[ais.length]; System.arraycopy(ais.buffer, ais.start + ais.pos, res, 0, ais.length); return res; }
java
public void addPages() { page = new CreateComponentStartPage(selection); addPage(page); integrationComponentPage = new CreateIntegrationComponentPage(selection); addPage(integrationComponentPage); serviceDescriptionComponentPage = new CreateServiceDescriptionComponentPage(selection); addPage(serviceDescr...
java
@SuppressWarnings("unchecked") public REC next() { checkDirection(true); ORecordInternal<?> record = getRecord(); // ITERATE UNTIL THE NEXT GOOD RECORD while (hasNext()) { record = getTransactionEntry(); if (record != null) return (REC) record; if ((record = readCurrentRecord(null, ...
java
public ORecordIteratorCluster<REC> setRange(final long iFrom, final long iEnd) { firstClusterPosition = iFrom; rangeTo = iEnd; current.clusterPosition = firstClusterPosition; return this; }
java
public long getRangeFrom() { final long limit = (liveUpdated ? database.getStorage().getClusterDataRange(current.clusterId)[1] : firstClusterPosition) - 1; if (rangeFrom > -1) return Math.max(rangeFrom, limit); return limit; }
java
public long getRangeTo() { final long limit = (liveUpdated ? database.getStorage().getClusterDataRange(current.clusterId)[1] : lastClusterPosition) + 1; if (rangeTo > -1) return Math.min(rangeTo, limit); return limit; }
java
public AisMessage getMessage() { AisMessage m = aisParser.parse(aisMessage, nmea.getSource(), padBits); return m; }
java
public Object command(final OCommandRequestText iCommand) { final OCommandExecutor executor = OCommandManager.instance().getExecutor(iCommand); executor.setProgressListener(iCommand.getProgressListener()); executor.parse(iCommand); return executeCommand(iCommand, executor); }
java
public long pushPosition(final long iPosition) throws IOException { final int position = getHoles() * RECORD_SIZE; file.allocateSpace(RECORD_SIZE); file.writeLong(position, iPosition); if (OLogManager.instance().isDebugEnabled()) OLogManager.instance().debug(this, "Pushed new hole %s/#%d ...
java
public long popLastEntryPosition() throws IOException { // BROWSE IN ASCENDING ORDER UNTIL A GOOD POSITION IS FOUND (!=-1) for (int pos = getHoles() - 1; pos >= 0; --pos) { final long recycledPosition = file.readLong(pos * RECORD_SIZE); if (recycledPosition > -1) { if (OLogManager.ins...
java
public boolean removeEntryWithPosition(final long iPosition) throws IOException { // BROWSE IN ASCENDING ORDER UNTIL THE REQUESTED POSITION IS FOUND boolean canShrink = true; for (int pos = getHoles() - 1; pos >= 0; --pos) { final long recycledPosition = file.readLong(pos * RECORD_SIZE); ...
java
public void requestModificationLock() { lock.readLock().lock(); if (!veto) return; if (throwException) { lock.readLock().unlock(); throw new OModificationOperationProhibitedException("Modification requests are prohibited"); } boolean wasInterrupted = false; Thread ...
java
public OClass setSuperClass(final OClass iSuperClass) { getDatabase().checkSecurity(ODatabaseSecurityResources.SCHEMA, ORole.PERMISSION_UPDATE); final String cmd = String.format("alter class %s superclass %s", name, iSuperClass.getName()); getDatabase().command(new OCommandSQL(cmd)).execute(); setSu...
java
private OClass addBaseClasses(final OClass iBaseClass) { if (baseClasses == null) baseClasses = new ArrayList<OClass>(); if (baseClasses.contains(iBaseClass)) return this; baseClasses.add(iBaseClass); // ADD CLUSTER IDS OF BASE CLASS TO THIS CLASS AND ALL SUPER-CLASSES OClas...
java
public void truncate() throws IOException { getDatabase().checkSecurity(ODatabaseSecurityResources.CLASS, ORole.PERMISSION_UPDATE); getDatabase().getStorage().callInLock(new Callable<Object>() { public Object call() throws Exception { for (int id : clusterIds) { getDatabase().getS...
java
private void addPolymorphicClusterIds(final OClassImpl iBaseClass) { boolean found; for (int i : iBaseClass.polymorphicClusterIds) { found = false; for (int k : polymorphicClusterIds) { if (i == k) { found = true; break; } } if (!found) { ...
java
protected long[] allocateSpace(final int iRecordSize) throws IOException { // IT'S PREFEREABLE TO FIND SPACE WITHOUT ENLARGE ANY FILES: FIND THE FIRST FILE WITH FREE SPACE TO USE OFile file; for (int i = 0; i < files.length; ++i) { file = files[i]; if (file.getFreeSpace() >= iRecordSize) ...
java
private void deleteHoleRecords() { listener.onMessage("\nDelete temporary records..."); final ORecordId rid = new ORecordId(); final ODocument doc = new ODocument(rid); for (String recId : recordToDelete) { doc.reset(); rid.fromString(recId); doc.delete(); } listener...
java
public PrintStream createStatusPrintStream() { return new PrintStream(new OutputStream() { StringBuffer sb = new StringBuffer(); @Override public void write(int b) throws IOException { if (b == '\n') { String str = sb.toString(); sb.delete(0, sb.length()); writeLine(str); } else { ...
java
protected void writeLine(final String line) { getContainer().getShell().getDisplay().syncExec( new Runnable() { public void run() { if (statusTextArea != null) { statusTextArea.setText(line + '\n' + statusTextArea.getText()); } } } ); }
java
public Object attemptTrade(String summonerInternalName, int championId) { return client.sendRpcAndWait(SERVICE, "attemptTrade", summonerInternalName, championId, false); }
java
public Object acceptTrade(String summonerInternalName, int championId) { return client.sendRpcAndWait(SERVICE, "attemptTrade", summonerInternalName, championId, true); }
java
public MigrationConfiguration getMigrationConfiguration(String configurationName) throws IOException, LightblueException { DataFindRequest findRequest = new DataFindRequest("migrationConfiguration", null); findRequest.where(Query.and( Query.withValue("configurationName", Quer...
java
public MigrationConfiguration loadMigrationConfiguration(String migrationConfigurationId) throws IOException, LightblueException { DataFindRequest findRequest = new DataFindRequest("migrationConfiguration", null); findRequest.where(Query.withValue("_id", Query.eq, migrationConfigurationId));...
java
public void createControllers(MigrationConfiguration[] configurations) throws Exception { for (MigrationConfiguration cfg : configurations) { MigrationProcess process = migrationMap.get(cfg.get_id()); if (process == null) { LOGGER.debug("Creating a controller thread for c...
java
public OIdentifiable getKeyAt(final int iIndex) { if (rids != null && rids[iIndex] != null) return rids[iIndex]; final ORecordId rid = itemFromStream(iIndex); if (rids != null) rids[iIndex] = rid; return rid; }
java
public void close() { if (indexManager != null) indexManager.flush(); if (schema != null) schema.close(); if (security != null) security.close(); }
java
public MuleMessage doHttpSendRequest(String url, String method, String payload, String contentType) { Map<String, String> properties = new HashMap<String, String>(); properties.put("http.method", method); properties.put("Content-Type", contentType); MuleMessage response = send(url, payload,...
java
public MuleMessage doHttpReceiveRequest(String url, String method, String acceptConentType, String acceptCharSet) { Map<String, String> properties = new HashMap<String, String>(); properties.put("http.method", method); properties.put("Accept", acceptConentType); properties.put("Accept-...
java
public byte[] toByteArray() { if (this.pos == this.length) return this.buffer; else { byte[] res = new byte[this.pos]; System.arraycopy(this.buffer, 0, res, 0, this.pos); return res; } }
java
@Override public void write(byte[] b, int off, int len) { this.checkIncreaseArray(len); System.arraycopy(b, off, this.buffer, this.pos, len); this.pos += len; }
java
public void writeTag(int tagClass, boolean primitive, int tag) throws AsnException { if (tag < 0) throw new AsnException("Tag must not be negative"); if (tag <= 30) { int toEncode = (tagClass & 0x03) << 6; toEncode |= (primitive ? 0 : 1) << 5; toEncode |= tag & 0x1F; this.write(toEn...
java
public void writeLength(int v) throws IOException { if (v == Tag.Indefinite_Length) { this.write(0x80); return; } else if (v > 0x7F) { int count; byte[] buf = new byte[4]; if ((v & 0xFF000000) > 0) { buf[0] = (byte)((v >> 24) & 0xFF); ...
java
public void FinalizeContent( int lenPos ) { if (lenPos == Tag.Indefinite_Length) { this.write(0); this.write(0); } else { int length = this.pos - lenPos - 1; if (length <= 0x7F) { this.buffer[lenPos] = (byte) length; } else { int count; byte[] buf = new byte[4]; ...
java
private static byte _getByte(int startIndex, BitSetStrictLength set) throws AsnException { int count = 8; byte data = 0; // if (set.length() - 1 < startIndex) { // throw new AsnException(); // } while (count > 0) { if (set.length() - 1 < startIndex) { break; } else { boolean ...
java