MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / rdataFromString

Method rdataFromString

src/main/java/core/org/xbill/DNS/SVCBBase.java:679–739  ·  view source on GitHub ↗
(Tokenizer st, Name origin)

Source from the content-addressed store, hash-verified

677 }
678
679 @Override
680 protected void rdataFromString(Tokenizer st, Name origin) throws IOException {
681 svcPriority = st.getUInt16();
682 targetName = st.getName(origin);
683 svcParams.clear();
684 while (true) {
685 String keyStr = null;
686 String valueStr = null;
687 Tokenizer.Token t = st.get();
688 if (!t.isString()) {
689 break;
690 }
691 int indexOfEquals = t.value.indexOf('=');
692 if (indexOfEquals == -1) {
693 // No "=" is key with no value case, leave value string as null
694 keyStr = t.value;
695 } else if (indexOfEquals == t.value.length() - 1) {
696 // Ends with "=" means the next token is quoted string with the value
697 keyStr = t.value.substring(0, indexOfEquals);
698 Tokenizer.Token valueToken = st.get();
699 if (!valueToken.isString()) {
700 throw new TextParseException("Expected value for parameter key '" + keyStr + "'");
701 }
702 valueStr = valueToken.value;
703 } else if (indexOfEquals > 0) {
704 // If "=" is in the middle then need to split the key and value from this token
705 keyStr = t.value.substring(0, indexOfEquals);
706 valueStr = t.value.substring(indexOfEquals + 1);
707 } else {
708 throw new TextParseException("Expected valid parameter key=value for '" + t.value + "'");
709 }
710
711 ParameterBase param;
712 int key = parameters.getValue(keyStr);
713 if (key == -1) {
714 throw new TextParseException("Expected a valid parameter key for '" + keyStr + "'");
715 }
716 if (svcParams.containsKey(key)) {
717 throw new TextParseException("Duplicate parameter key for '" + keyStr + "'");
718 }
719 Supplier<ParameterBase> factory = parameters.getFactory(key);
720 if (factory != null) {
721 param = factory.get();
722 } else {
723 param = new ParameterUnknown(key);
724 }
725 param.fromString(valueStr);
726 svcParams.put(key, param);
727 }
728
729 if (svcPriority > 0 && svcParams.isEmpty()) {
730 throw new TextParseException(
731 "At least one parameter value must be specified for ServiceMode");
732 }
733 if (svcPriority == 0 && !svcParams.isEmpty()) {
734 throw new TextParseException("No parameter values allowed for AliasMode");
735 }
736 if (!checkMandatoryParams()) {

Callers 1

stringToWireMethod · 0.45

Calls 13

fromStringMethod · 0.95
checkMandatoryParamsMethod · 0.95
getUInt16Method · 0.80
isStringMethod · 0.80
indexOfMethod · 0.80
lengthMethod · 0.80
getFactoryMethod · 0.80
getNameMethod · 0.65
clearMethod · 0.45
getMethod · 0.45
getValueMethod · 0.45
putMethod · 0.45

Tested by 1

stringToWireMethod · 0.36