code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public void
add(int val, String str) {
check(val);
Integer value = toInteger(val);
str = sanitize(str);
strings.put(str, value);
values.put(value, str);
} | java |
public void
addAll(Mnemonic source) {
if (wordcase != source.wordcase)
throw new IllegalArgumentException(source.description +
": wordcases do not match");
strings.putAll(source.strings);
values.putAll(source.values);
} | java |
public String
getText(int val) {
check(val);
String str = (String) values.get(toInteger(val));
if (str != null)
return str;
str = Integer.toString(val);
if (prefix != null)
return prefix + str;
return str;
} | java |
public int
getValue(String str) {
str = sanitize(str);
Integer value = (Integer) strings.get(str);
if (value != null) {
return value.intValue();
}
if (prefix != null) {
if (str.startsWith(prefix)) {
int val = parseNumeric(str.substring(prefix.length()));
if (val >= 0) {
return val;
}
}
}
if (n... | java |
String
rrToString() {
StringBuffer sb = new StringBuffer();
sb.append(preference);
sb.append(" ");
sb.append(map822);
sb.append(" ");
sb.append(mapX400);
return sb.toString();
} | java |
public PublicKey
getPublicKey() throws DNSSEC.DNSSECException {
if (publicKey != null)
return publicKey;
publicKey = DNSSEC.toPublicKey(this);
return publicKey;
} | java |
public synchronized void
addRecord(Record r, int cred, Object o) {
Name name = r.getName();
int type = r.getRRsetType();
if (!Type.isRR(type))
return;
Element element = findElement(name, type, cred);
if (element == null) {
CacheRRset crrset = new CacheRRset(r, cred, maxcache);
addRRset(crrset, cred);
} else... | java |
public synchronized void
addRRset(RRset rrset, int cred) {
long ttl = rrset.getTTL();
Name name = rrset.getName();
int type = rrset.getType();
Element element = findElement(name, type, 0);
if (ttl == 0) {
if (element != null && element.compareCredibility(cred) <= 0)
removeElement(name, type);
} else {
if (... | java |
public synchronized void
addNegative(Name name, int type, SOARecord soa, int cred) {
long ttl = 0;
if (soa != null)
ttl = soa.getTTL();
Element element = findElement(name, type, 0);
if (ttl == 0) {
if (element != null && element.compareCredibility(cred) <= 0)
removeElement(name, type);
} else {
if (elemen... | java |
protected synchronized SetResponse
lookup(Name name, int type, int minCred) {
int labels;
int tlabels;
Element element;
Name tname;
Object types;
SetResponse sr;
labels = name.labels();
for (tlabels = labels; tlabels >= 1; tlabels--) {
boolean isRoot = (tlabels == 1);
boolean isExact = (tlabels == labels)... | java |
public SetResponse
lookupRecords(Name name, int type, int minCred) {
return lookup(name, type, minCred);
} | java |
public String
getString() throws IOException {
Token next = get();
if (!next.isString()) {
throw exception("expected a string");
}
return next.value;
} | java |
public long
getLong() throws IOException {
String next = _getIdentifier("an integer");
if (!Character.isDigit(next.charAt(0)))
throw exception("expected an integer");
try {
return Long.parseLong(next);
} catch (NumberFormatException e) {
throw exception("expected an integer");
}
} | java |
public long
getTTL() throws IOException {
String next = _getIdentifier("a TTL value");
try {
return TTL.parseTTL(next);
}
catch (NumberFormatException e) {
throw exception("expected a TTL value");
}
} | java |
public long
getTTLLike() throws IOException {
String next = _getIdentifier("a TTL-like value");
try {
return TTL.parse(next, false);
}
catch (NumberFormatException e) {
throw exception("expected a TTL-like value");
}
} | java |
public Name
getName(Name origin) throws IOException {
String next = _getIdentifier("a name");
try {
Name name = Name.fromString(next, origin);
if (!name.isAbsolute())
throw new RelativeNameException(name);
return name;
}
catch (TextParseException e) {
throw exception(e.getMessage());
}
} | java |
public byte []
getAddressBytes(int family) throws IOException {
String next = _getIdentifier("an address");
byte [] bytes = Address.toByteArray(next, family);
if (bytes == null)
throw exception("Invalid address: " + next);
return bytes;
} | java |
public InetAddress
getAddress(int family) throws IOException {
String next = _getIdentifier("an address");
try {
return Address.getByAddress(next, family);
}
catch (UnknownHostException e) {
throw exception(e.getMessage());
}
} | java |
public void
getEOL() throws IOException {
Token next = get();
if (next.type != EOL && next.type != EOF) {
throw exception("expected EOL or EOF");
}
} | java |
private String
remainingStrings() throws IOException {
StringBuffer buffer = null;
while (true) {
Tokenizer.Token t = get();
if (!t.isString())
break;
if (buffer == null)
buffer = new StringBuffer();
... | java |
public byte []
getHexString() throws IOException {
String next = _getIdentifier("a hex string");
byte [] array = base16.fromString(next);
if (array == null)
throw exception("invalid hex encoding");
return array;
} | java |
public byte []
getBase32String(base32 b32) throws IOException {
String next = _getIdentifier("a base32 string");
byte [] array = b32.fromString(next);
if (array == null)
throw exception("invalid base32 encoding");
return array;
} | java |
public static int
compare(long serial1, long serial2) {
if (serial1 < 0 || serial1 > MAX32)
throw new IllegalArgumentException(serial1 + " out of range");
if (serial2 < 0 || serial2 > MAX32)
throw new IllegalArgumentException(serial2 + " out of range");
long diff = serial1 - serial2;
if (diff >= MAX32)
diff -... | java |
public static long
increment(long serial) {
if (serial < 0 || serial > MAX32)
throw new IllegalArgumentException(serial + " out of range");
if (serial == MAX32)
return 0;
return serial + 1;
} | java |
public Message
send(Message query) throws IOException {
if (Options.check("verbose"))
System.err.println("Sending to " +
address.getAddress().getHostAddress() +
":" + address.getPort());
if (query.getHeader().getOpcode() == Opcode.QUERY) {
Record question = query.getQuestion();
if (question != nu... | java |
public Object
sendAsync(final Message query, final ResolverListener listener) {
final Object id;
synchronized (this) {
id = new Integer(uniqueID++);
}
Record question = query.getQuestion();
String qname;
if (question != null)
qname = question.getName().toString();
else
qname = "(none)";
String name = this... | java |
public static void
set(String option) {
if (table == null)
table = new HashMap();
table.put(option.toLowerCase(), "true");
} | java |
public static boolean
check(String option) {
if (table == null)
return false;
return (table.get(option.toLowerCase()) != null);
} | java |
public static String
value(String option) {
if (table == null)
return null;
return ((String)table.get(option.toLowerCase()));
} | java |
public static int
intValue(String option) {
String s = value(option);
if (s != null) {
try {
int val = Integer.parseInt(s);
if (val > 0)
return (val);
}
catch (NumberFormatException e) {
}
}
return (-1);
} | java |
public void
run() {
try {
Message response = res.send(query);
listener.receiveMessage(id, response);
}
catch (Exception e) {
listener.handleException(id, e);
}
} | java |
String
rrToString() {
StringBuffer sb = new StringBuffer();
sb.append(byteArrayToString(cpu, true));
sb.append(" ");
sb.append(byteArrayToString(os, true));
return sb.toString();
} | java |
public RRset []
answers() {
if (type != SUCCESSFUL)
return null;
List l = (List) data;
return (RRset []) l.toArray(new RRset[l.size()]);
} | java |
public static Record
newRecord(Name name, int type, int dclass, long ttl) {
if (!name.isAbsolute())
throw new RelativeNameException(name);
Type.check(type);
DClass.check(dclass);
TTL.check(ttl);
return getEmptyRecord(name, type, dclass, ttl, false);
} | java |
public static Record
newRecord(Name name, int type, int dclass) {
return newRecord(name, type, dclass, 0);
} | java |
public static Record
fromWire(byte [] b, int section) throws IOException {
return fromWire(new DNSInput(b), section, false);
} | java |
public byte []
toWire(int section) {
DNSOutput out = new DNSOutput();
toWire(out, section, null);
return out.toByteArray();
} | java |
protected static byte []
byteArrayFromString(String s) throws TextParseException {
byte [] array = s.getBytes();
boolean escaped = false;
boolean hasEscapes = false;
for (int i = 0; i < array.length; i++) {
if (array[i] == '\\') {
hasEscapes = true;
break;
}
}
if (!hasEscapes) {
if (array.length > 25... | java |
protected static String
byteArrayToString(byte [] array, boolean quote) {
StringBuffer sb = new StringBuffer();
if (quote)
sb.append('"');
for (int i = 0; i < array.length; i++) {
int b = array[i] & 0xFF;
if (b < 0x20 || b >= 0x7f) {
sb.append('\\');
sb.append(byteFormat.format(b));
} else if (b == '"'... | java |
protected static String
unknownToString(byte [] data) {
StringBuffer sb = new StringBuffer();
sb.append("\\# ");
sb.append(data.length);
sb.append(" ");
sb.append(base16.toString(data));
return sb.toString();
} | java |
public boolean
sameRRset(Record rec) {
return (getRRsetType() == rec.getRRsetType() &&
dclass == rec.dclass &&
name.equals(rec.name));
} | java |
public String
printFlags() {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < 16; i++)
if (validFlag(i) && getFlag(i)) {
sb.append(Flags.string(i));
sb.append(" ");
}
return sb.toString();
} | java |
public static synchronized Cache
getDefaultCache(int dclass) {
DClass.check(dclass);
Cache c = (Cache) defaultCaches.get(Mnemonic.toInteger(dclass));
if (c == null) {
c = new Cache(dclass);
defaultCaches.put(Mnemonic.toInteger(dclass), c);
}
return c;
} | java |
public static synchronized void
setDefaultCache(Cache cache, int dclass) {
DClass.check(dclass);
defaultCaches.put(Mnemonic.toInteger(dclass), cache);
} | java |
public static synchronized void
setDefaultSearchPath(String [] domains) throws TextParseException {
if (domains == null) {
defaultSearchPath = null;
return;
}
Name [] newdomains = new Name[domains.length];
for (int i = 0; i < domains.length; i++)
newdomains[i] = Name.fromString(domains[i], Name.root);
defaul... | java |
public void
setSearchPath(String [] domains) throws TextParseException {
if (domains == null) {
this.searchPath = null;
return;
}
Name [] newdomains = new Name[domains.length];
for (int i = 0; i < domains.length; i++)
newdomains[i] = Name.fromString(domains[i], Name.root);
this.searchPath = newdomains;
} | java |
public void
setCache(Cache cache) {
if (cache == null) {
this.cache = new Cache(dclass);
this.temporary_cache = true;
} else {
this.cache = cache;
this.temporary_cache = false;
}
} | java |
public Record []
run() {
if (done)
reset();
if (name.isAbsolute())
resolve(name, null);
else if (searchPath == null)
resolve(name, Name.root);
else {
if (name.labels() > defaultNdots)
resolve(name, Name.root);
if (done)
return answers;
for (int i = 0; i < searchPath.length; i++) {
resolve(name... | java |
public String
getErrorString() {
checkDone();
if (error != null)
return error;
switch (result) {
case SUCCESSFUL: return "successful";
case UNRECOVERABLE: return "unrecoverable error";
case TRY_AGAIN: return "try again";
case HOST_NOT_FOUND: return "host not found";
case TYPE_NOT_FOUND: return "type not... | java |
public static int
value(String s, boolean numberok) {
int val = types.getValue(s);
if (val == -1 && numberok) {
val = types.getValue("TYPE" + s);
}
return val;
} | java |
public InetAddress
getAddress() {
try {
if (name == null)
return InetAddress.getByAddress(address);
else
return InetAddress.getByAddress(name.toString(),
address);
} catch (UnknownHostException e) {
return null;
}
} | java |
public synchronized void
addRR(Record r) {
if (rrs.size() == 0) {
safeAddRR(r);
return;
}
Record first = first();
if (!r.sameRRset(first))
throw new IllegalArgumentException("record does not match " +
"rrset");
if (r.getTTL() != first.getTTL()) {
if (r.getTTL() > first.getTTL()) {
r = r.cloneR... | java |
private boolean
findProperty() {
String prop;
List lserver = new ArrayList(0);
List lsearch = new ArrayList(0);
StringTokenizer st;
prop = System.getProperty("dns.server");
if (prop != null) {
st = new StringTokenizer(prop, ",");
while (st.hasMoreTokens())
addServer(st.nextToken(), lserver);
}
prop = S... | java |
private void
find95() {
String s = "winipcfg.out";
try {
Process p;
p = Runtime.getRuntime().exec("winipcfg /all /batch " + s);
p.waitFor();
File f = new File(s);
findWin(new FileInputStream(f));
new File(s).delete();
}
catch (Exception e) {
return;
}
} | java |
private void
findNT() {
try {
Process p;
p = Runtime.getRuntime().exec("ipconfig /all");
findWin(p.getInputStream());
p.destroy();
}
catch (Exception e) {
return;
}
} | java |
public void
writeU16(int val) {
check(val, 16);
need(2);
array[pos++] = (byte)((val >>> 8) & 0xFF);
array[pos++] = (byte)(val & 0xFF);
} | java |
public void
writeU16At(int val, int where) {
check(val, 16);
if (where > pos - 2)
throw new IllegalArgumentException("cannot write past " +
"end of data");
array[where++] = (byte)((val >>> 8) & 0xFF);
array[where++] = (byte)(val & 0xFF);
} | java |
public void
writeU32(long val) {
check(val, 32);
need(4);
array[pos++] = (byte)((val >>> 24) & 0xFF);
array[pos++] = (byte)((val >>> 16) & 0xFF);
array[pos++] = (byte)((val >>> 8) & 0xFF);
array[pos++] = (byte)(val & 0xFF);
} | java |
public void
writeByteArray(byte [] b, int off, int len) {
need(len);
System.arraycopy(b, off, array, pos, len);
pos += len;
} | java |
public void
writeCountedString(byte [] s) {
if (s.length > 0xFF) {
throw new IllegalArgumentException("Invalid counted string");
}
need(1 + s.length);
array[pos++] = (byte)(s.length & 0xFF);
writeByteArray(s, 0, s.length);
} | java |
public byte []
hashName(Name name) throws NoSuchAlgorithmException
{
return NSEC3Record.hashName(name, hashAlg, iterations, salt);
} | java |
public static boolean
supportedType(int type) {
Type.check(type);
return (type == Type.PTR || type == Type.CNAME || type == Type.DNAME ||
type == Type.A || type == Type.AAAA || type == Type.NS);
} | java |
public Record
nextRecord() throws IOException {
if (current > end)
return null;
String namestr = substitute(namePattern, current);
Name name = Name.fromString(namestr, origin);
String rdata = substitute(rdataPattern, current);
current += step;
return Record.fromString(name, type, dclass, ttl, rdata, origin);
} | java |
public Record []
expand() throws IOException {
List list = new ArrayList();
for (long i = start; i < end; i += step) {
String namestr = substitute(namePattern, current);
Name name = Name.fromString(namestr, origin);
String rdata = substitute(rdataPattern, current);
list.add(Record.fromString(name, type, dclas... | java |
String
rrToString() {
StringBuffer sb = new StringBuffer();
sb.append(mailbox);
sb.append(" ");
sb.append(textDomain);
return sb.toString();
} | java |
public static String
format(Date date) {
Calendar c = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
StringBuffer sb = new StringBuffer();
c.setTime(date);
sb.append(w4.format(c.get(Calendar.YEAR)));
sb.append(w2.format(c.get(Calendar.MONTH)+1));
sb.append(w2.format(c.get(Calendar.DAY_OF_MONTH)));
sb.appen... | java |
public static Date
parse(String s) throws TextParseException {
if (s.length() != 14) {
throw new TextParseException("Invalid time encoding: " + s);
}
Calendar c = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
c.clear();
try {
int year = Integer.parseInt(s.substring(0, 4));
int month = Integer.parseInt... | java |
public InetAddress
getAddress() {
try {
if (name == null)
return InetAddress.getByAddress(toArray(addr));
else
return InetAddress.getByAddress(name.toString(),
toArray(addr));
} catch (UnknownHostException e) {
return null;
}
} | java |
String
rrToString() {
StringBuffer sb = new StringBuffer();
sb.append(responsibleAddress);
sb.append(" ");
sb.append(errorAddress);
return sb.toString();
} | java |
public static void
verify(RRset rrset, RRSIGRecord rrsig, DNSKEYRecord key) throws DNSSECException
{
if (!matches(rrsig, key))
throw new KeyMismatchException(key, rrsig);
Date now = new Date();
if (now.compareTo(rrsig.getExpire()) > 0)
throw new SignatureExpiredException(rrsig.getExpire(), now);
if (now.compar... | java |
static byte []
generateDSDigest(DNSKEYRecord key, int digestid)
{
MessageDigest digest;
try {
switch (digestid) {
case DSRecord.Digest.SHA1:
digest = MessageDigest.getInstance("sha-1");
break;
case DSRecord.Digest.SHA256:
digest = MessageDigest.getInstance("sha-256");
break;
case DSRecord.Digest.G... | java |
private static Map<String, String> parseKeyValueMap(String kvString, Function<String, String> valueMapper) {
return Stream.of(
Optional.ofNullable(kvString)
.map(StringUtils::trimAllWhitespace)
.filter(StringUtils::hasText)
... | java |
public boolean setNonnull(HttpResponse response) {
Preconditions.checkNotNull(response);
if (set(response)) {
callback.completed(response);
return true;
} else {
return false;
}
} | java |
public static void registerAccessor(Class<?> documentType, DocumentAccessor accessor) {
Assert.notNull(documentType, "documentType may not be null");
Assert.notNull(accessor, "accessor may not be null");
if (accessors.containsKey(documentType)) {
DocumentAccessor existing = getAccessor(documentType);
LOG.wa... | java |
public static void setId(Object document, String id) {
DocumentAccessor d = getAccessor(document);
if (d.hasIdMutator()) {
d.setId(document, id);
}
} | java |
public static List<String> parseAttachmentNames(JsonParser documentJsonParser) throws IOException
{
documentJsonParser.nextToken();
JsonToken jsonToken;
while((jsonToken = documentJsonParser.nextToken()) != JsonToken.END_OBJECT)
{
if(CouchDbDocument.ATTACHMENTS_NAME.equa... | java |
@JsonAnySetter
public void setAnonymous(String key, Object value) {
anonymous().put(key, value);
} | java |
protected SettableBeanProperty constructSettableProperty(
DeserializationConfig config, BeanDescription beanDesc,
String name, AnnotatedMethod setter, JavaType type) {
// need to ensure method is callable (for non-public)
if (config
.isEnabled(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS)) {
Method memb... | java |
private List<String> parseRows(JsonParser jp, List<String> result) throws IOException {
while(jp.nextToken() == JsonToken.START_OBJECT) {
while(jp.nextToken() == JsonToken.FIELD_NAME)
{
String fieldName = jp.getCurrentName();
jp.nextToken();
... | java |
public static BulkDeleteDocument of(Object o) {
return new BulkDeleteDocument(Documents.getId(o), Documents.getRevision(o));
} | java |
public Options param(String name, String value) {
options.put(name, value);
return this;
} | java |
protected ViewQuery createQuery(String viewName) {
return new ViewQuery()
.dbPath(db.path())
.designDocId(stdDesignDocumentId)
.viewName(viewName);
} | java |
protected List<T> queryView(String viewName, ComplexKey key) {
return db.queryView(createQuery(viewName)
.includeDocs(true)
.key(key),
type);
} | java |
private void backOff() {
try {
Thread.sleep(new Random().nextInt(400));
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
}
} | java |
public void load(Reader in) {
try {
doLoad(in);
} catch (Exception e) {
throw Exceptions.propagate(e);
}
} | java |
public void write(Collection<?> objects, boolean allOrNothing, OutputStream out) {
try {
JsonGenerator jg = objectMapper.getFactory().createGenerator(out, JsonEncoding.UTF8);
jg.writeStartObject();
if (allOrNothing) {
jg.writeBooleanField("all_or_nothing", true);
}
jg.writeArrayFieldStart("docs");
... | java |
protected void applyDefaultConfiguration(ObjectMapper om) {
om.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, this.writeDatesAsTimestamps);
om.setSerializationInclusion(JsonInclude.Include.NON_NULL);
} | java |
public Socket connectSocket(
final Socket sock,
final String host,
final int port,
final InetAddress localAddress,
int localPort,
final HttpParams params
) throws IOException {
if (host == null) {
throw new IllegalArgumentException("Target host ma... | java |
public Socket createSocket(
final Socket socket,
final String host,
final int port,
final boolean autoClose
) throws IOException, UnknownHostException {
SSLSocket sslSocket = (SSLSocket) this.socketfactory.createSocket(
socket,
host,
... | java |
public static Method findMethod(Class<?> clazz, String name) {
for (Method me : clazz.getDeclaredMethods()) {
if (me.getName().equalsIgnoreCase(name)) {
return me;
}
}
if (clazz.getSuperclass() != null) {
return findMethod(clazz.getSuperclass(), name);
}
return null;
} | java |
public static DbAccessException createDbAccessException(HttpResponse hr) {
JsonNode responseBody;
try {
InputStream content = hr.getContent();
if (content != null) {
responseBody = responseBodyAsNode(IOUtils.toString(content));
} else {
responseBod... | java |
@Override
public void afterPropertiesSet() throws Exception {
if (couchDBProperties != null) {
new DirectFieldAccessor(this).setPropertyValues(couchDBProperties);
}
LOG.info("Starting couchDb connector on {}:{}...", new Object[]{host,port});
LOG.debug("host: {}", host);
LOG.debug("port: {}", port);
LOG... | java |
public Map<String, DesignDocument.View> generateViews(
final Object repository) {
final Map<String, DesignDocument.View> views = new HashMap<String, DesignDocument.View>();
final Class<?> repositoryClass = repository.getClass();
final Class<?> handledType = repository instanceof CouchDbRepositorySupport<?> ? ... | java |
public boolean mergeWith(DesignDocument dd, boolean updateOnDiff) {
boolean changed = mergeViews(dd.views(), updateOnDiff);
changed = mergeFunctions(lists(), dd.lists(), updateOnDiff) || changed;
changed = mergeFunctions(shows(), dd.shows(), updateOnDiff) || changed;
changed = mergeFunct... | java |
public boolean isSubType(String typeName) throws AtlasException {
HierarchicalType cType = typeSystem.getDataType(HierarchicalType.class, typeName);
return (cType == this || cType.superTypePaths.containsKey(getName()));
} | java |
public List<EntityAuditEvent> listEvents(String entityId, String startKey, short n)
throws AtlasException {
if (LOG.isDebugEnabled()) {
LOG.debug("Listing events for entity id {}, starting timestamp {}, #records {}", entityId, startKey, n);
}
Table table = null;
... | java |
public static org.apache.hadoop.conf.Configuration getHBaseConfiguration(Configuration atlasConf) throws AtlasException {
Configuration subsetAtlasConf =
ApplicationProperties.getSubsetConfiguration(atlasConf, CONFIG_PREFIX);
org.apache.hadoop.conf.Configuration hbaseConf = HBaseConfigur... | java |
public static Titan0Edge createEdge(Titan0Graph graph, Edge source) {
if (source == null) {
return null;
}
return new Titan0Edge(graph, source);
} | java |
public static Titan0Vertex createVertex(Titan0Graph graph, Vertex source) {
if (source == null) {
return null;
}
return new Titan0Vertex(graph, source);
} | java |
protected String errorMessage(String input, Exception e) {
return String.format("Invalid parameter: %s (%s)", input, e.getMessage());
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.