Methods Summary |
---|
public void | decrementForegroundRefCount()decrement the foregroundRefCount
_foregroundRefCount--;
|
public int | getForegroundRefCount()get the foregroundRefCount
return _foregroundRefCount;
|
public java.lang.String | getLockType()get the lock type
return _lockType;
|
public void | incrementForegroundRefCount()increment the foregroundRefCount
_foregroundRefCount++;
|
public boolean | isBackgroundLocked()return whether lock is background locked
if(_lockType == null) {
return false;
}
return (_lockType.equals(BACKGROUND_LOCK));
|
public boolean | isForegroundLocked()return whether lock is foreground locked
if(_lockType == null) {
return false;
}
return (_lockType.equals(FOREGROUND_LOCK));
|
public boolean | isLocked()return whether lock is locked (either foreground or background)
return (_lockType != null);
|
public synchronized boolean | lockBackground()if possible, the lock will be background locked
if the lock is already foreground locked the method
will return false and the lock remains foreground locked
(i.e. lock failed) otherwise it will return true (lock succeeded)
if(isForegroundLocked()) {
return false;
}
setLockType(BACKGROUND_LOCK);
setForegroundRefCount(0);
return true;
|
public synchronized boolean | lockForeground()if possible, the lock will be foreground locked
if it was already foreground locked; it will
remain so and the foregroundRefCount will be incremented
if the lock is already background locked the method
will return false and the lock remains background locked
(i.e. lock failed) otherwise it will return true (lock succeeded)
if(isBackgroundLocked()) {
return false;
}
if(isForegroundLocked()) {
incrementForegroundRefCount();
} else {
setForegroundRefCount(1);
}
setLockType(FOREGROUND_LOCK);
return true;
|
public void | setForegroundRefCount(int foregroundRefCount)set the foregroundRefCount
_foregroundRefCount = foregroundRefCount;
|
public void | setLockType(java.lang.String lockType)set the lock type - lockType must be BACKGROUND_LOCK or FOREGROUND_LOCK
_lockType = lockType;
|
public java.lang.String | toString()returns String representation of the state of the lock
StringBuffer sb = new StringBuffer(50);
sb.append("_lockType= " + _lockType);
sb.append("\n" + "foregroundRefCount= " + _foregroundRefCount);
return sb.toString();
|
public void | unlock()unlock the lock
if background locked the lock will become fully unlocked
if foreground locked the lock will become fully unlocked
if foregroundRefCount was 1; otherwise it will
decrement the foregroundRefCount and the lock will remain foreground locked
if(!isLocked())
return;
if(isBackgroundLocked()) {
this.setLockType(null);
this.setForegroundRefCount(0);
return;
}
if(isForegroundLocked()) {
decrementForegroundRefCount();
if(_foregroundRefCount == 0) {
this.setLockType(null);
}
}
|
public void | unlockBackground()unlock the lock for the background locked case
the lock will be unlocked
//unlock if the lock is background locked
//else do nothing
if(!isLocked())
return;
if(isBackgroundLocked()) {
this.setLockType(null);
this.setForegroundRefCount(0);
return;
}
|
public void | unlockForeground()unlock the lock for the foreground locked case
the lock will be unlocked
if foregroundRefCount was 1; otherwise it will
decrement the foregroundRefCount and the lock will remain foreground locked
//unlock if the lock is foreground locked
//else do nothing
if(!isLocked())
return;
if(isForegroundLocked()) {
decrementForegroundRefCount();
if(_foregroundRefCount == 0) {
this.setLockType(null);
}
}
|
public void | unlockForegroundCompletely()unlock the lock
this is a force unlock; foregroundRefCount is ignored
//unlock completely if the lock is foreground locked
//else do nothing
if(!isLocked())
return;
if(isForegroundLocked()) {
this.setForegroundRefCount(0);
this.setLockType(null);
}
|