mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-04 07:35:24 +02:00
[cleanup] format and javadoc
This commit is contained in:
parent
cb9c4eb6cc
commit
408451566e
3 changed files with 53 additions and 64 deletions
|
@ -15,6 +15,7 @@
|
|||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.references;
|
||||
|
||||
import org.eclipse.rse.core.references.IRSEBasePersistableReferencedObject;
|
||||
|
||||
/**
|
||||
|
@ -24,36 +25,31 @@ import org.eclipse.rse.core.references.IRSEBasePersistableReferencedObject;
|
|||
* so unique that it can be used after restoration from disk to resolve a pointer to this
|
||||
* specific object, in memory.
|
||||
*/
|
||||
public class SystemPersistableReferencedObjectHelper
|
||||
extends SystemReferencedObjectHelper
|
||||
implements IRSEBasePersistableReferencedObject
|
||||
{
|
||||
public class SystemPersistableReferencedObjectHelper extends SystemReferencedObjectHelper implements IRSEBasePersistableReferencedObject {
|
||||
private String referenceName;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for SystemPersistableReferencedObjectHelper
|
||||
* @param referenceName The unique name that can be stored to identify this object.
|
||||
*/
|
||||
protected SystemPersistableReferencedObjectHelper(String referenceName)
|
||||
{
|
||||
protected SystemPersistableReferencedObjectHelper(String referenceName) {
|
||||
super();
|
||||
setReferenceName(referenceName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the unique reference name of this object, as set in the constructor
|
||||
* @return the unique reference name of this object, as set in the constructor
|
||||
*/
|
||||
public String getReferenceName()
|
||||
{
|
||||
public String getReferenceName() {
|
||||
return referenceName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the unique reference name of this object. Overrides what was set in
|
||||
* the constructor. Typically called on rename operation.
|
||||
* @param name the name of this particular reference.
|
||||
*/
|
||||
public void setReferenceName(String name)
|
||||
{
|
||||
public void setReferenceName(String name) {
|
||||
this.referenceName = name;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.references;
|
||||
|
||||
import org.eclipse.rse.core.model.RSEModelObject;
|
||||
import org.eclipse.rse.core.references.IRSEBaseReferencingObject;
|
||||
import org.eclipse.rse.core.references.IRSEReferencedObject;
|
||||
|
||||
|
||||
/**
|
||||
* A class to encapsulate the operations required of an object which
|
||||
* supports references to it by other objects (SystemReferencingObject).
|
||||
|
@ -33,58 +33,57 @@ import org.eclipse.rse.core.references.IRSEReferencedObject;
|
|||
/**
|
||||
* @lastgen class SystemReferencedObjectImpl Impl implements SystemReferencedObject, EObject {}
|
||||
*/
|
||||
public abstract class SystemReferencedObject extends RSEModelObject implements IRSEReferencedObject
|
||||
{
|
||||
protected SystemReferencedObjectHelper helper = null;
|
||||
|
||||
public abstract class SystemReferencedObject extends RSEModelObject implements IRSEReferencedObject {
|
||||
protected SystemReferencedObjectHelper helper = null;
|
||||
|
||||
/**
|
||||
* Default constructor. Typically called by EMF factory method.
|
||||
*/
|
||||
protected SystemReferencedObject()
|
||||
{
|
||||
protected SystemReferencedObject() {
|
||||
super();
|
||||
helper = new SystemReferencedObjectHelper();
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
// IRSEReferencedObject methods...
|
||||
// ----------------------------------
|
||||
/**
|
||||
* Add a reference, increment reference count, return new count
|
||||
* @param ref the referencing object
|
||||
* @return new count of how many referencing objects reference this object.
|
||||
*/
|
||||
public int addReference(IRSEBaseReferencingObject ref)
|
||||
{
|
||||
public int addReference(IRSEBaseReferencingObject ref) {
|
||||
return helper.addReference(ref);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a reference, decrement reference count, return new count
|
||||
* @param ref the referencing object
|
||||
* @return new count of how many referencing objects reference this object.
|
||||
*/
|
||||
public int removeReference(IRSEBaseReferencingObject ref)
|
||||
{
|
||||
public int removeReference(IRSEBaseReferencingObject ref) {
|
||||
return helper.removeReference(ref);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a count of how many referencing objects reference this object.
|
||||
* @return a count of how many referencing objects reference this object.
|
||||
*/
|
||||
public int getReferenceCount()
|
||||
{
|
||||
public int getReferenceCount() {
|
||||
return helper.getReferenceCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the list of referenced objects.
|
||||
*/
|
||||
public void removeAllReferences()
|
||||
{
|
||||
helper.removeAllReferences();
|
||||
public void removeAllReferences() {
|
||||
helper.removeAllReferences();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all referencing objects of this object
|
||||
* @return a list of all referencing objects of this object
|
||||
*/
|
||||
public IRSEBaseReferencingObject[] getReferencingObjects()
|
||||
{
|
||||
public IRSEBaseReferencingObject[] getReferencingObjects() {
|
||||
return helper.getReferencingObjects();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -15,34 +15,32 @@
|
|||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.references;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.rse.core.references.IRSEBaseReferencedObject;
|
||||
import org.eclipse.rse.core.references.IRSEBaseReferencingObject;
|
||||
|
||||
|
||||
/**
|
||||
* This is a class that implements all the methods in the IRSEReferencedObject.
|
||||
* It makes implementing this interface trivial.
|
||||
* The easiest use of this class is to subclass it, but since that is not
|
||||
* always possible, it is not abstract and hence can be leveraged via containment.
|
||||
*/
|
||||
public class SystemReferencedObjectHelper implements IRSEBaseReferencedObject
|
||||
{
|
||||
public class SystemReferencedObjectHelper implements IRSEBaseReferencedObject {
|
||||
private Vector referencingObjects = new Vector();
|
||||
|
||||
/**
|
||||
* Constructor for SystemReferencedObjectHelper
|
||||
*/
|
||||
public SystemReferencedObjectHelper()
|
||||
{
|
||||
public SystemReferencedObjectHelper() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IRSEBaseReferencedObject#addReference(IRSEBaseReferencingObject)
|
||||
*/
|
||||
public int addReference(IRSEBaseReferencingObject ref)
|
||||
{
|
||||
public int addReference(IRSEBaseReferencingObject ref) {
|
||||
referencingObjects.addElement(ref);
|
||||
return referencingObjects.size();
|
||||
}
|
||||
|
@ -50,50 +48,46 @@ public class SystemReferencedObjectHelper implements IRSEBaseReferencedObject
|
|||
/**
|
||||
* @see IRSEBaseReferencedObject#removeReference(IRSEBaseReferencingObject)
|
||||
*/
|
||||
public int removeReference(IRSEBaseReferencingObject ref)
|
||||
{
|
||||
public int removeReference(IRSEBaseReferencingObject ref) {
|
||||
int before = referencingObjects.size();
|
||||
referencingObjects.removeElement(ref);
|
||||
int after = referencingObjects.size();
|
||||
assertThis((after == (before - 1)), "removeReference failed for "+ref); //$NON-NLS-1$
|
||||
assertThis((after == (before - 1)), "removeReference failed for " + ref); //$NON-NLS-1$
|
||||
return referencingObjects.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IRSEBaseReferencedObject#getReferenceCount()
|
||||
*/
|
||||
public int getReferenceCount()
|
||||
{
|
||||
public int getReferenceCount() {
|
||||
return referencingObjects.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the list of referenced objects.
|
||||
*/
|
||||
public void removeAllReferences()
|
||||
{
|
||||
public void removeAllReferences() {
|
||||
referencingObjects.removeAllElements();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IRSEBaseReferencedObject#getReferencingObjects()
|
||||
*/
|
||||
public IRSEBaseReferencingObject[] getReferencingObjects()
|
||||
{
|
||||
public IRSEBaseReferencingObject[] getReferencingObjects() {
|
||||
IRSEBaseReferencingObject[] references = new IRSEBaseReferencingObject[referencingObjects.size()];
|
||||
for (int idx=0; idx<referencingObjects.size(); idx++)
|
||||
references[idx] = (IRSEBaseReferencingObject)referencingObjects.elementAt(idx);
|
||||
for (int idx = 0; idx < referencingObjects.size(); idx++)
|
||||
references[idx] = (IRSEBaseReferencingObject) referencingObjects.elementAt(idx);
|
||||
return references;
|
||||
}
|
||||
|
||||
/**
|
||||
* Little assertion method for debugging purposes
|
||||
* FIXME Move to common place, protected seems not appropriate
|
||||
*/
|
||||
protected void assertThis(boolean assertion, String msg)
|
||||
{
|
||||
if (!assertion)
|
||||
System.out.println("ASSERTION FAILED IN SystemReferencedObject: " + msg); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Assertion method for debugging purposes. All instances of assertion failure should be removed by
|
||||
* release.
|
||||
* @param assertion a boolean (usually an expression) that is to be tested
|
||||
* @param msg the message printed on System.out
|
||||
*/
|
||||
protected void assertThis(boolean assertion, String msg) {
|
||||
if (!assertion) System.out.println("ASSERTION FAILED IN SystemReferencedObject: " + msg); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue