示例#1
0
  @Test
  public void testSplitProtocolBuild() {
    Protocol p = new Protocol("P", null, "foo");
    p.addProp("property", "some value");

    String protocolString = p.toString();
    final int mid = protocolString.length() / 2;
    String[] parts = {
      protocolString.substring(0, mid), protocolString.substring(mid),
    };

    Protocol parsedStringProtocol = org.apache.avro.Protocol.parse(protocolString);
    Protocol parsedArrayOfStringProtocol =
        org.apache.avro.Protocol.parse(
            protocolString.substring(0, mid), protocolString.substring(mid));

    assertNotNull(parsedStringProtocol);
    assertNotNull(parsedArrayOfStringProtocol);
    assertEquals(parsedStringProtocol.toString(), parsedArrayOfStringProtocol.toString());
  }
示例#2
0
  private boolean testValidProtocol(Element el, Attribute attr, Set<Protocol> protocols) {
    // try to resolve relative urls to abs, and optionally update the attribute so output html has
    // abs.
    // rels without a baseuri get removed
    String value = el.absUrl(attr.getKey());
    if (value.length() == 0)
      value = attr.getValue(); // if it could not be made abs, run as-is to allow custom unknown
    // protocols
    if (!preserveRelativeLinks) attr.setValue(value);

    for (Protocol protocol : protocols) {
      String prot = protocol.toString() + ":";
      if (value.toLowerCase().startsWith(prot)) {
        return true;
      }
    }
    return false;
  }
  private void selectPortNumber() {
    // Go and get default port number according to the selected protocol
    Protocol protocol = (Protocol) protocolList.getSelectedItem();

    if (protocol.toString().equals("FILE")) {
      enableFields(false);

      this.isPortTextFieldDirty = false;

      return;
    } else {
      enableFields(true);
    }

    // if user types in a port number
    // or empties port number field
    // then do not set protocol's default port number
    if (isPortTextFieldDirty() && portTextField.isEditValid()) {
      return;
    }

    portTextField.setValue(protocol.getPort());
  }
 public String getProtocolAsString() {
   return protocol.toString();
 }