本文整理汇总了Java中org.xbill.DNS.TXTRecord.getStrings方法的典型用法代码示例。如果您正苦于以下问题:Java TXTRecord.getStrings方法的具体用法?Java TXTRecord.getStrings怎么用?Java TXTRecord.getStrings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xbill.DNS.TXTRecord
的用法示例。
在下文中一共展示了TXTRecord.getStrings方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: concatenateTxtRecordValues
import org.xbill.DNS.TXTRecord; //导入方法依赖的package包/类
private String concatenateTxtRecordValues(Record[] records) {
if (records == null || records.length == 0)
return null;
StringBuilder builder = new StringBuilder();
for (Record record : records) {
TXTRecord txtRecord = (TXTRecord) record;
if (builder.length() != 0)
builder.append(EOL);
for (Object string : txtRecord.getStrings()) {
if (builder.length() != 0)
builder.append(EOL);
builder.append(string);
}
}
return builder.toString();
}
示例2: getASN
import org.xbill.DNS.TXTRecord; //导入方法依赖的package包/类
public static Long getASN(final InetAddress adr)
{
try
{
final Name postfix;
if (adr instanceof Inet6Address)
postfix = Name.fromConstantString("origin6.asn.cymru.com");
else
postfix = Name.fromConstantString("origin.asn.cymru.com");
final Name name = getReverseIPName(adr, postfix);
System.out.println("lookup: " + name);
final Lookup lookup = new Lookup(name, Type.TXT);
lookup.setResolver(new SimpleResolver());
lookup.setCache(null);
final Record[] records = lookup.run();
if (lookup.getResult() == Lookup.SUCCESSFUL)
for (final Record record : records)
if (record instanceof TXTRecord)
{
final TXTRecord txt = (TXTRecord) record;
@SuppressWarnings("unchecked")
final List<String> strings = txt.getStrings();
if (strings != null && !strings.isEmpty())
{
final String result = strings.get(0);
final String[] parts = result.split(" ?\\| ?");
if (parts != null && parts.length >= 1)
return new Long(parts[0].split(" ")[0]);
}
}
}
catch (final Exception e)
{
}
return null;
}
示例3: getASName
import org.xbill.DNS.TXTRecord; //导入方法依赖的package包/类
public static String getASName(final long asn)
{
try
{
final Name postfix = Name.fromConstantString("asn.cymru.com.");
final Name name = new Name(String.format("AS%d", asn), postfix);
System.out.println("lookup: " + name);
final Lookup lookup = new Lookup(name, Type.TXT);
lookup.setResolver(new SimpleResolver());
lookup.setCache(null);
final Record[] records = lookup.run();
if (lookup.getResult() == Lookup.SUCCESSFUL)
for (final Record record : records)
if (record instanceof TXTRecord)
{
final TXTRecord txt = (TXTRecord) record;
@SuppressWarnings("unchecked")
final List<String> strings = txt.getStrings();
if (strings != null && !strings.isEmpty())
{
System.out.println(strings);
final String result = strings.get(0);
final String[] parts = result.split(" ?\\| ?");
if (parts != null && parts.length >= 1)
return parts[4];
}
}
}
catch (final Exception e)
{
}
return null;
}
示例4: getAScountry
import org.xbill.DNS.TXTRecord; //导入方法依赖的package包/类
public static String getAScountry(final long asn)
{
try
{
final Name postfix = Name.fromConstantString("asn.cymru.com.");
final Name name = new Name(String.format("AS%d", asn), postfix);
System.out.println("lookup: " + name);
final Lookup lookup = new Lookup(name, Type.TXT);
lookup.setResolver(new SimpleResolver());
lookup.setCache(null);
final Record[] records = lookup.run();
if (lookup.getResult() == Lookup.SUCCESSFUL)
for (final Record record : records)
if (record instanceof TXTRecord)
{
final TXTRecord txt = (TXTRecord) record;
@SuppressWarnings("unchecked")
final List<String> strings = txt.getStrings();
if (strings != null && !strings.isEmpty())
{
final String result = strings.get(0);
final String[] parts = result.split(" ?\\| ?");
if (parts != null && parts.length >= 1)
return parts[1];
}
}
}
catch (final Exception e)
{
}
return null;
}
示例5: resolveAPITXT
import org.xbill.DNS.TXTRecord; //导入方法依赖的package包/类
/**
* Adapted from https://code.google.com/p/asmack/source/browse/src/custom/org/jivesoftware/smack/util/DNSUtil.java
*
* @param domain
* @return
* @throws TextParseException
*/
@SuppressWarnings("unchecked")
private static String resolveAPITXT(String domain) throws TextParseException {
Lookup lookup = new Lookup(TXT_PREFIX + domain, Type.TXT);
Record recs[] = lookup.run();
if (recs == null) {
throw new RuntimeException("Could not lookup domain.");
}
Map<String, String> stringMap = null;
for (Record rec : recs) {
String rData = rec.rdataToString().replaceAll("\"", "");
List<String> rDataTokens = Arrays.asList(rData.split("\\s+"));
TXTRecord record = new TXTRecord(rec.getName(), rec.getDClass(),
rec.getTTL(), rDataTokens);
List<String> strings = record.getStrings();
if (strings != null && strings.size() > 0) {
stringMap = parseStrings(strings);
break;
}
}
if (stringMap == null) {
throw new RuntimeException("Domain has no TXT records for buddycloud.");
}
String host = stringMap.get("host");
String protocol = stringMap.get("protocol");
String path = stringMap.get("path");
String port = stringMap.get("port");
path = path == null || path.equals("/") ? "" : path;
port = port == null ? "" : port;
return protocol + "://" + host + ":" + port + path;
}
示例6: getTXTRecord
import org.xbill.DNS.TXTRecord; //导入方法依赖的package包/类
public String
getTXTRecord(
String query )
throws UnknownHostException
{
try{
Lookup l = new Lookup( query, Type.TXT );
setCache( null, l );
l.run();
Record[] records = l.getAnswers();
if ( records != null ){
for ( Record r: records ){
TXTRecord txt = (TXTRecord)r;
List<String> strs = (List<String>)txt.getStrings();
if ( strs.size() > 0 ){
return( strs.get( 0 ));
}
}
}
return( null );
}catch( Throwable e ){
throw( new UnknownHostException( query + ": " + Debug.getNestedExceptionMessage( e )));
}
}