public StringBuilder encode(StringBuilder buffer) { if (userInfo != null) { userInfo.encode(buffer); buffer.append(AT); hostPort.encode(buffer); } else { hostPort.encode(buffer); } return buffer; }
/** * Returns the host part of this ViaHeader. * * @return the string value of the host */ public String getHost() { if (sentBy == null) return null; else { Host host = sentBy.getHost(); if (host == null) return null; else return host.getHostname(); } }
/** * Set the host part of this ViaHeader to the newly supplied <code>host</code> parameter. * * @return host - the new interger value of the host of this ViaHeader * @throws ParseException which signals that an error has been reached unexpectedly while parsing * the host value. */ public void setHost(String host) throws ParseException { if (sentBy == null) sentBy = new HostPort(); try { Host h = new Host(host); sentBy.setHost(h); } catch (Exception e) { throw new NullPointerException(" host parameter is null"); } }
/** Encode the body of this header (the stuff that follows headerName). A.K.A headerValue. */ protected String encodeBody() { StringBuffer encoding = new StringBuffer(); encoding.append(sentProtocol.encode()).append(SP).append(sentBy.encode()); if (!parameters.isEmpty()) { encoding.append(SEMICOLON).append(parameters.encode()); } if (comment != null) { encoding.append(SP).append(LPAREN).append(comment).append(RPAREN); } return encoding.toString(); }
/** * Set the port part of this ViaHeader to the newly supplied <code>port</code> parameter. * * @param port - the new integer value of the port of this ViaHeader */ public void setPort(int port) /*throws InvalidArgumentException*/ { /* * InvalidArgumentException not in 1.1 API * if ( port!=-1 && (port<1 || port>65535)) { throw new InvalidArgumentException( "Port value out of range -1, [1..65535]" ); } */ if (sentBy == null) sentBy = new HostPort(); sentBy.setPort(port); }
@Override public String getId() { return host.toString() + ":" + partition; }
@Override public int hashCode() { return 13 * host.hashCode() + partition; }
@Override public boolean equals(Object o) { GlobalPartitionId other = (GlobalPartitionId) o; return host.equals(other.host) && partition == other.partition; }
/** * Returns the port part of this ViaHeader. * * @return the integer value of the port */ public int getPort() { if (sentBy == null) return -1; return sentBy.getPort(); }
/** * set the Host of the Via Header * * @param host String to set */ public void setHost(Host host) { if (sentBy == null) { sentBy = new HostPort(); } sentBy.setHost(host); }
/** remove the port. */ public void removePort() { sentBy.removePort(); }
/** * Set the port. * * @param port int to set */ public void setPort(int port) { if (hostPort == null) hostPort = new HostPort(); hostPort.setPort(port); }
/** * set the host. * * @param host Host to set */ public void setHost(Host host) { if (hostPort == null) hostPort = new HostPort(); hostPort.setHost(host); }
/** remove the port. */ public void removePort() { if (hostPort != null) hostPort.removePort(); }
/** * Get the port. * * @return int port (-1) if port is not set. */ public int getPort() { if (hostPort == null) return -1; else return hostPort.getPort(); }
/** * Get the host name. * * @return Host (null if not set) */ public Host getHost() { if (hostPort == null) return null; else return hostPort.getHost(); }