Boolean.valueOf(x).booleanValue() -> Boolean.parseBoolean(x)

This commit is contained in:
zzz
2012-09-28 17:50:41 +00:00
parent 7c8ba61f03
commit fb5d0cd760
54 changed files with 107 additions and 108 deletions

View File

@@ -91,7 +91,7 @@ public class Blocklist {
static final String BLOCKLIST_FILE_DEFAULT = "blocklist.txt";
public void startup() {
if (! Boolean.valueOf(_context.getProperty(PROP_BLOCKLIST_ENABLED, "true")).booleanValue())
if (! _context.getBooleanPropertyDefaultTrue(PROP_BLOCKLIST_ENABLED))
return;
String file = _context.getProperty(PROP_BLOCKLIST_FILE, BLOCKLIST_FILE_DEFAULT);
// Maybe someday we'll read in multiple files and merge them

View File

@@ -348,7 +348,7 @@ public class InNetMessagePool implements Service {
_dispatchThreaded = DEFAULT_DISPATCH_THREADED;
String threadedStr = _context.getProperty(PROP_DISPATCH_THREADED);
if (threadedStr != null) {
_dispatchThreaded = Boolean.valueOf(threadedStr).booleanValue();
_dispatchThreaded = Boolean.parseBoolean(threadedStr);
}
if (_dispatchThreaded) {
_context.statManager().createRateStat("pool.dispatchDataTime", "How long a tunnel dispatch takes", "Tunnels", new long[] { 10*60*1000l, 60*60*1000l, 24*60*60*1000l });

View File

@@ -80,7 +80,7 @@ public class MessageHistory {
String getFilename() { return _historyFile; }
private void updateSettings() {
_doLog = Boolean.valueOf(_context.getProperty(PROP_KEEP_MESSAGE_HISTORY)).booleanValue();
_doLog = _context.getBooleanProperty(PROP_KEEP_MESSAGE_HISTORY);
_historyFile = _context.getProperty(PROP_MESSAGE_HISTORY_FILENAME, DEFAULT_MESSAGE_HISTORY_FILENAME);
}

View File

@@ -176,7 +176,7 @@ public class Router implements RouterClock.ClockShiftListener {
// Do we copy all the data files to the new directory? default false
String migrate = System.getProperty("i2p.dir.migrate");
boolean migrateFiles = Boolean.valueOf(migrate).booleanValue();
boolean migrateFiles = Boolean.parseBoolean(migrate);
String userDir = WorkingDir.getWorkingDir(envProps, migrateFiles);
// Use the router.config file specified in the router.configLocation property
@@ -196,7 +196,7 @@ public class Router implements RouterClock.ClockShiftListener {
envProps.putAll(_config);
// This doesn't work, guess it has to be in the static block above?
// if (Boolean.valueOf(envProps.getProperty("router.disableIPv6")).booleanValue())
// if (Boolean.parseBoolean(envProps.getProperty("router.disableIPv6")))
// System.setProperty("java.net.preferIPv4Stack", "true");
if (envProps.getProperty("i2p.dir.config") == null)
@@ -630,7 +630,7 @@ public class Router implements RouterClock.ClockShiftListener {
return true;
String h = _context.getProperty(PROP_HIDDEN_HIDDEN);
if (h != null)
return Boolean.valueOf(h).booleanValue();
return Boolean.parseBoolean(h);
return _context.commSystem().isInBadCountry();
}

View File

@@ -237,7 +237,7 @@ public class TunnelPoolSettings {
private static final boolean getBoolean(String str, boolean defaultValue) {
if (str == null) return defaultValue;
boolean v = Boolean.valueOf(str).booleanValue() ||
boolean v = Boolean.parseBoolean(str) ||
(str != null && "YES".equals(str.toUpperCase(Locale.US)));
return v;
}

View File

@@ -326,7 +326,7 @@ class ClientManager {
if (destHash == null) return true;
ClientConnectionRunner runner = getRunner(destHash);
if (runner == null) return true;
return !Boolean.valueOf(runner.getConfig().getOptions().getProperty(ClientManagerFacade.PROP_CLIENT_ONLY)).booleanValue();
return !Boolean.parseBoolean(runner.getConfig().getOptions().getProperty(ClientManagerFacade.PROP_CLIENT_ONLY));
}
/**

View File

@@ -169,7 +169,7 @@ class ClientMessageEventListener implements I2CPMessageReader.I2CPMessageEventLi
}
// Auth, since 0.8.2
if (_enforceAuth && Boolean.valueOf(_context.getProperty("i2cp.auth")).booleanValue()) {
if (_enforceAuth && _context.getBooleanProperty("i2cp.auth")) {
String configUser = _context.getProperty("i2cp.username");
String configPW = _context.getProperty("i2cp.password");
if (configUser != null && configPW != null) {

View File

@@ -452,7 +452,7 @@ public class OutboundClientMessageOneShotJob extends JobImpl {
// Per-message flag == false overrides session option which is default true
String allow = _clientMessage.getSenderConfig().getOptions().getProperty(BUNDLE_REPLY_LEASESET);
boolean allowLeaseBundle = SendMessageOptions.getSendLeaseSet(sendFlags) &&
(allow == null || Boolean.valueOf(allow).booleanValue());
(allow == null || Boolean.parseBoolean(allow));
if (allowLeaseBundle) {
// If we want an ack, bundle a leaseSet...
//replyLeaseSet = getReplyLeaseSet(wantACK);

View File

@@ -45,7 +45,7 @@ class HarvesterJob extends JobImpl {
public static final String PROP_ENABLED = "netDb.shouldHarvest";
private boolean harvestDirectly() {
return Boolean.valueOf(getContext().getProperty("netDb.harvestDirectly", "false")).booleanValue();
return getContext().getBooleanProperty("netDb.harvestDirectly");
}
public HarvesterJob(RouterContext context, KademliaNetworkDatabaseFacade facade) {

View File

@@ -220,7 +220,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
}
String enforce = _context.getProperty(PROP_ENFORCE_NETID);
if (enforce != null)
_enforceNetId = Boolean.valueOf(enforce).booleanValue();
_enforceNetId = Boolean.parseBoolean(enforce);
else
_enforceNetId = DEFAULT_ENFORCE_NETID;
_ds.restart();
@@ -246,7 +246,7 @@ public class KademliaNetworkDatabaseFacade extends NetworkDatabaseFacade {
String dbDir = _context.getProperty(PROP_DB_DIR, DEFAULT_DB_DIR);
String enforce = _context.getProperty(PROP_ENFORCE_NETID);
if (enforce != null)
_enforceNetId = Boolean.valueOf(enforce).booleanValue();
_enforceNetId = Boolean.parseBoolean(enforce);
else
_enforceNetId = DEFAULT_ENFORCE_NETID;

View File

@@ -136,7 +136,7 @@ class SearchJob extends JobImpl {
// Returning false essentially enables kademlia as a backup to floodfill for search responses.
if (FloodfillNetworkDatabaseFacade.floodfillEnabled(ctx))
return false;
return Boolean.valueOf(ctx.getProperty("netDb.floodfillOnly", DEFAULT_FLOODFILL_ONLY + "")).booleanValue();
return ctx.getProperty("netDb.floodfillOnly", DEFAULT_FLOODFILL_ONLY);
}
/***

View File

@@ -527,7 +527,7 @@ public class Reseeder {
/******
public static void main(String args[]) {
if ( (args != null) && (args.length == 1) && (!Boolean.valueOf(args[0]).booleanValue()) ) {
if ( (args != null) && (args.length == 1) && (!Boolean.parseBoolean(args[0])) ) {
System.out.println("Not reseeding, as requested");
return; // not reseeding on request
}

View File

@@ -54,7 +54,7 @@ public class BootCommSystemJob extends JobImpl {
private void startupDb() {
Job bootDb = new BootNetworkDbJob(getContext());
boolean useTrusted = Boolean.valueOf(getContext().getProperty(PROP_USE_TRUSTED_LINKS)).booleanValue();
boolean useTrusted = getContext().getBooleanProperty(PROP_USE_TRUSTED_LINKS);
if (useTrusted) {
_log.debug("Using trusted links...");
getContext().jobQueue().addJob(new BuildTrustedLinksJob(getContext(), bootDb));

View File

@@ -64,7 +64,7 @@ public class RouterWatchdog implements Runnable {
private boolean shutdownOnHang() {
// prop default false
if (!Boolean.valueOf(_context.getProperty("watchdog.haltOnHang")).booleanValue())
if (!_context.getBooleanProperty("watchdog.haltOnHang"))
return false;
// Client manager starts complaining after 10 minutes, and we run every minute,

View File

@@ -72,7 +72,7 @@ public class RouterTimestamper extends Timestamper {
// so the property must be set at startup.
// We still need to be instantiated since the router calls clock().getTimestamper().waitForInitialization()
String disabled = ctx.getProperty(PROP_DISABLED, DEFAULT_DISABLED);
if (Boolean.valueOf(disabled).booleanValue()) {
if (Boolean.parseBoolean(disabled)) {
_initialized = true;
return;
}
@@ -321,7 +321,7 @@ public class RouterTimestamper extends Timestamper {
_context.getProperty(PROP_QUERY_FREQUENCY, DEFAULT_QUERY_FREQUENCY));
String disabled = _context.getProperty(PROP_DISABLED, DEFAULT_DISABLED);
_disabled = Boolean.valueOf(disabled).booleanValue();
_disabled = Boolean.parseBoolean(disabled);
_concurringServers = Math.min(4, Math.max(1,
_context.getProperty(PROP_CONCURRING_SERVERS, DEFAULT_CONCURRING_SERVERS)));

View File

@@ -331,7 +331,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
if (_log.shouldLog(Log.INFO))
_log.info("old: " + ohost + " config: " + name + " auto: " + enabled + " status: " + status);
if (enabled.equals("always") ||
(Boolean.valueOf(enabled).booleanValue() && status == STATUS_OK)) {
(Boolean.parseBoolean(enabled) && status == STATUS_OK)) {
String nhost = UDPAddr.getOption(UDPAddress.PROP_HOST);
if (_log.shouldLog(Log.INFO))
_log.info("old: " + ohost + " config: " + name + " new: " + nhost);
@@ -354,7 +354,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
changed = true;
} else if (ohost == null || ohost.length() <= 0) {
return;
} else if (Boolean.valueOf(enabled).booleanValue() && status != STATUS_OK) {
} else if (Boolean.parseBoolean(enabled) && status != STATUS_OK) {
// UDP transitioned to not-OK, turn off NTCP address
// This will commonly happen at startup if we were initially OK
// because UPnP was successful, but a subsequent SSU Peer Test determines

View File

@@ -91,7 +91,7 @@ class GeoIP {
*/
/******
public void lookup() {
if (! Boolean.valueOf(_context.getProperty(PROP_GEOIP_ENABLED, "true")).booleanValue()) {
if (! _context.getBooleanPropertyDefaultTrue(PROP_GEOIP_ENABLED)) {
_pendingSearch.clear();
return;
}
@@ -105,7 +105,7 @@ class GeoIP {
* Results will be added to the table and available via get() after completion.
*/
public void blockingLookup() {
if (! Boolean.valueOf(_context.getProperty(PROP_GEOIP_ENABLED, "true")).booleanValue()) {
if (! _context.getBooleanPropertyDefaultTrue(PROP_GEOIP_ENABLED)) {
_pendingSearch.clear();
return;
}

View File

@@ -362,7 +362,7 @@ public class TransportManager implements TransportEventListener {
}
// Use UDP port for NTCP too - see comment in NTCPTransport.getRequestedPort() for why this is here
if (t.getStyle().equals(NTCPTransport.STYLE) && port <= 0 &&
Boolean.valueOf(_context.getProperty(CommSystemFacadeImpl.PROP_I2NP_NTCP_AUTO_PORT)).booleanValue()) {
_context.getBooleanProperty(CommSystemFacadeImpl.PROP_I2NP_NTCP_AUTO_PORT)) {
Transport udp = getTransport(UDPTransport.STYLE);
if (udp != null)
port = t.getRequestedPort();

View File

@@ -708,7 +708,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
private boolean getIsPortFixed() {
String prop = _context.getProperty(PROP_FIXED_PORT);
if (prop != null)
return Boolean.valueOf(prop).booleanValue();
return Boolean.parseBoolean(prop);
int status = getReachabilityStatus();
return status != CommSystemFacade.STATUS_REJECT_UNSOLICITED;
}
@@ -1503,7 +1503,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
* it's usually false positives.
******************
String forceIntroducers = _context.getProperty(PROP_FORCE_INTRODUCERS);
if ( (forceIntroducers != null) && (Boolean.valueOf(forceIntroducers).booleanValue()) ) {
if ( (forceIntroducers != null) && (Boolean.parseBoolean(forceIntroducers)) ) {
if (_log.shouldLog(Log.INFO))
_log.info("Force introducers specified");
return true;

View File

@@ -460,7 +460,7 @@ public abstract class TunnelPeerSelector {
else
val = ctx.getProperty(PROP_OUTBOUND_CLIENT_EXCLUDE_UNREACHABLE, DEFAULT_OUTBOUND_CLIENT_EXCLUDE_UNREACHABLE);
boolean rv = (val != null ? Boolean.valueOf(val).booleanValue() : def);
boolean rv = (val != null ? Boolean.parseBoolean(val) : def);
//System.err.println("Filter unreachable? " + rv + " (inbound? " + isInbound + ", exploratory? " + isExploratory);
return rv;
}
@@ -490,7 +490,7 @@ public abstract class TunnelPeerSelector {
else
val = ctx.getProperty(PROP_OUTBOUND_CLIENT_EXCLUDE_SLOW);
boolean rv = (val != null ? Boolean.valueOf(val).booleanValue() : def);
boolean rv = (val != null ? Boolean.parseBoolean(val) : def);
//System.err.println("Filter unreachable? " + rv + " (inbound? " + isInbound + ", exploratory? " + isExploratory);
return rv;
}
@@ -519,7 +519,7 @@ public abstract class TunnelPeerSelector {
else
val = ctx.getProperty(PROP_OUTBOUND_CLIENT_EXCLUDE_UPTIME);
boolean rv = (val != null ? Boolean.valueOf(val).booleanValue() : def);
boolean rv = (val != null ? Boolean.parseBoolean(val) : def);
//System.err.println("Filter unreachable? " + rv + " (inbound? " + isInbound + ", exploratory? " + isExploratory);
return rv;
}