Use (final) static wherever possible for method signature clarity/performance

pull/2/head
rfc2822 11 years ago
parent e667de8992
commit 520ec21d9e

@ -67,7 +67,7 @@ import at.bitfire.davdroid.syncadapter.DavSyncAdapter;
public class Event extends Resource {
private final static String TAG = "davdroid.Event";
private TimeZoneRegistry tzRegistry = new DefaultTimeZoneRegistryFactory().createRegistry();
private final static TimeZoneRegistry tzRegistry = new DefaultTimeZoneRegistryFactory().createRegistry();
@Getter @Setter private String summary, location, description;
@ -307,13 +307,13 @@ public class Event extends Resource {
return false;
}
protected boolean hasNoTime(DateProperty date) {
protected static boolean hasNoTime(DateProperty date) {
if (date == null)
return false;
return !(date.getDate() instanceof DateTime);
}
String getTzId(DateProperty date) {
protected static String getTzId(DateProperty date) {
if (date == null)
return null;
@ -327,7 +327,7 @@ public class Event extends Resource {
}
/* guess matching Android timezone ID */
protected void validateTimeZone(DateProperty date) {
protected static void validateTimeZone(DateProperty date) {
if (date == null || date.isUtc() || hasNoTime(date))
return;

@ -838,7 +838,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
return syncAdapterURI(Data.CONTENT_URI);
}
protected String labelToXName(String label) {
protected static String labelToXName(String label) {
return "X-" + label.replaceAll(" ","_").replaceAll("[^\\p{L}\\p{Nd}\\-_]", "").toUpperCase(Locale.US);
}
@ -846,7 +846,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
return newDataInsertBuilder(dataURI(), Data.RAW_CONTACT_ID, raw_contact_id, backrefIdx);
}
protected String xNameToLabel(String xname) {
protected static String xNameToLabel(String xname) {
// "X-MY_PROPERTY"
// 1. ensure lower case -> "x-my_property"
// 2. remove x- from beginning -> "my_property"

@ -32,7 +32,7 @@ public class SyncManager {
private static final int MAX_MULTIGET_RESOURCES = 35;
public void synchronize(LocalCollection<? extends Resource> local, RemoteCollection<? extends Resource> remote, boolean manualSync, SyncResult syncResult) throws LocalStorageException, IOException, HttpException {
public static void synchronize(LocalCollection<? extends Resource> local, RemoteCollection<? extends Resource> remote, boolean manualSync, SyncResult syncResult) throws LocalStorageException, IOException, HttpException {
// PHASE 1: push local changes to server
int deletedRemotely = pushDeleted(local, remote),
addedRemotely = pushNew(local, remote),
@ -85,7 +85,7 @@ public class SyncManager {
}
private int pushDeleted(LocalCollection<? extends Resource> local, RemoteCollection<? extends Resource> remote) throws LocalStorageException, IOException, HttpException {
private static int pushDeleted(LocalCollection<? extends Resource> local, RemoteCollection<? extends Resource> remote) throws LocalStorageException, IOException, HttpException {
int count = 0;
long[] deletedIDs = local.findDeleted();
@ -111,7 +111,7 @@ public class SyncManager {
return count;
}
private int pushNew(LocalCollection<? extends Resource> local, RemoteCollection<? extends Resource> remote) throws LocalStorageException, IOException, HttpException {
private static int pushNew(LocalCollection<? extends Resource> local, RemoteCollection<? extends Resource> remote) throws LocalStorageException, IOException, HttpException {
int count = 0;
long[] newIDs = local.findNew();
Log.i(TAG, "Uploading " + newIDs.length + " new resource(s) (if not existing)");
@ -135,7 +135,7 @@ public class SyncManager {
return count;
}
private int pushDirty(LocalCollection<? extends Resource> local, RemoteCollection<? extends Resource> remote) throws LocalStorageException, IOException, HttpException {
private static int pushDirty(LocalCollection<? extends Resource> local, RemoteCollection<? extends Resource> remote) throws LocalStorageException, IOException, HttpException {
int count = 0;
long[] dirtyIDs = local.findDirty();
Log.i(TAG, "Uploading " + dirtyIDs.length + " modified resource(s) (if not changed)");
@ -160,7 +160,7 @@ public class SyncManager {
return count;
}
private int pullNew(LocalCollection<? extends Resource> local, RemoteCollection<? extends Resource> remote, Resource[] resourcesToAdd) throws LocalStorageException, IOException, HttpException {
private static int pullNew(LocalCollection<? extends Resource> local, RemoteCollection<? extends Resource> remote, Resource[] resourcesToAdd) throws LocalStorageException, IOException, HttpException {
int count = 0;
Log.i(TAG, "Fetching " + resourcesToAdd.length + " new remote resource(s)");
@ -177,7 +177,7 @@ public class SyncManager {
return count;
}
private int pullChanged(LocalCollection<? extends Resource> local, RemoteCollection<? extends Resource> remote, Resource[] resourcesToUpdate) throws LocalStorageException, IOException, HttpException {
private static int pullChanged(LocalCollection<? extends Resource> local, RemoteCollection<? extends Resource> remote, Resource[] resourcesToUpdate) throws LocalStorageException, IOException, HttpException {
int count = 0;
Log.i(TAG, "Fetching " + resourcesToUpdate.length + " updated remote resource(s)");

@ -353,11 +353,11 @@ public class WebDavResource {
/* helpers */
protected void checkResponse(HttpResponse response) throws HttpException {
protected static void checkResponse(HttpResponse response) throws HttpException {
checkResponse(response.getStatusLine());
}
protected void checkResponse(StatusLine statusLine) throws HttpException {
protected static void checkResponse(StatusLine statusLine) throws HttpException {
int code = statusLine.getStatusCode();
Log.d(TAG, "Received " + statusLine.getProtocolVersion() + " " + code + " " + statusLine.getReasonPhrase());

Loading…
Cancel
Save