@MinDoc(copyright="Copyright 2010 A. Weinert", author="Albrecht Weinert", version="V.32", lastModified="22.03.2021", lastModifiedBy="A. Weinert", usage="use for URLs and DAV", purpose="have the proxy settings handled") public final class ProxyProps extends Object implements AttrSettable
Modifier and Type | Field and Description |
---|---|
String |
proxyHost
Name of the proxy server.
|
String |
proxyPort
Port of the proxy server..
|
boolean |
proxySet
Use a proxy server when reading from URLs.
|
String |
socksProxyHost
Name of the socks proxy server.
|
String |
socksProxyPort
Port of the socks proxy server.
|
ILLEGAL_TYPE, ILLEGAL_VALUE, NO_ATTRIBUTE, NO_KNOWN_ATTRIBUTE, NO_VALUE, OK
Constructor and Description |
---|
ProxyProps()
Make with default values.
|
ProxyProps(Prop prop)
Make with default values overwritten by a Prop object.
|
Modifier and Type | Method and Description |
---|---|
void |
set(Prop prop)
Set by a Prop object.
|
int |
setAttribute(String name,
Object value)
Set a named attribute or property.
|
void |
setSystProxy()
Set the system's proxy properties according to this ProxyProps.
|
String |
toString()
State as String.
|
public boolean proxySet
proxyHost
,
proxyHost
, socksProxyHost
and
socksProxyPort
take effect.public String socksProxyHost
proxySet
public ProxyProps()
public ProxyProps(Prop prop)
public void set(Prop prop)
public void setSystProxy()
proxySet
is false only the system property proxySet
is
set so.public final int setAttribute(String name, Object value)
AttrSettable
CharSequence
or derived. It is
most strongly recommended that the type String
is always accepted
for any settable attribute / property.AttrSettable.NO_KNOWN_ATTRIBUTE
is returned, if name and
value are given (non null / empty), but this method just knows nothing
about a property name
. This (plus perhaps AttrSettable.NO_VALUE
if
other setters might accept null) is the only return value where
further delegation to other setters makes any sense. @Override public int setAttribute(final String name, final Object value){
if (name == null || name.isEmpty()) return NO_ATTRIBUTE;
final boolean isNull = value == null;
final Class<? extends Object> cl = isNull ? null : value.getClass();
final boolean isStringVal = !isNull && cl == java.lang.String.class;
// do own job; return 0 (OK) on set attribute
// return failure on implemented attributes, but wrong value or type
return NO_KNOWN_ATTRIBUTE; // not implemented here (try other setters)
} // setAttribute(String, Object)
Hint 2 for implementation (with prior delegation to like above):
@SuppressWarnings("null")
@Override public int setAttribute(final String name, final Object value) {
final int ret = super.setAttribute(name, value); // (1)
if (ret != NO_KNOWN_ATTRIBUTE) return ret; // all done by (1)
final boolean isNull = value == null;
final Class<? extends Object> cl = isNull ? null : value.getClass();
final boolean isStringVal = !isNull && cl == java.lang.String.class;
/// rest as above
setAttribute
in interface AttrSettable
name
- the name of the property to be set; null, empty and start with
< 'a' will be rejected with
NO_ATTRIBUTE
value
- the new value for the named propertyOK
) or rejected (with
NO_VALUE
,
ILLEGAL_TYPE
or
ILLEGAL_VALUE
)OK
, NO_ATTRIBUTE
,
NO_KNOWN_ATTRIBUTE
,
NO_VALUE
,
ILLEGAL_TYPE
or
ILLEGAL_VALUE