package com.perforce.wvcm;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.util.AbstractList;
import java.util.List;
import javax.wvcm.Location;
import javax.wvcm.PropertyNameList;
import javax.wvcm.Provider;
import javax.wvcm.ResourceList;
import javax.wvcm.WvcmException;
/**
* P4Provider.java
*
*
* Created: Mon Jan 05 17:04:41 2004
*
* @author <a href="mailto:">Paul Krause</a>
* @version 1.0
*/
public class P4Provider implements Provider {
private final ReferenceQueue referenceQueue = new ReferenceQueue();
/**
* Creates a new <code>P4Provider</code> instance.
*
*/
public P4Provider() {
} // P4Provider constructor
// Implementation of javax.wvcm.Provider
public Location location(String string) throws WvcmException {
return null;
}
public List serverWorkspaceFolderList(PropertyNameList pnl)
throws WvcmException
{
return null;
}
public List clientWorkspaceFolderList(PropertyNameList pnl)
throws WvcmException
{
return null;
}
public List serverSharedWorkspaceList(PropertyNameList pnl)
throws WvcmException
{
return null;
}
public ResourceList resourceList() {
return null;
}
public abstract class CachedList extends AbstractList {
private double growthFactor = 1.5;
private SoftReference[] listItems = new SoftReference[1];
/**
* Describe <code>get</code> method here.
*
* @param n an <code>int</code> index
* @return the <code>Object</code> at that index
* @exception IndexOutOfBoundException if n < 0 || n >= modCount
*/
public Object get(int n) {
if (n >= modCount) throw new IndexOutOfBoundsException(n + " >= " + modCount);
return listItems[n].get();
}
/**
* Describe <code>size</code> method here.
*
* @return the number of elements in this list
*/
public int size() {
return modCount;
}
/**
* Describe <code>add</code> method here.
*
* @param n an <code>int</code> index
* @param obj an <code>Object</code> referent
* @exception IndexOutOfBoundException if n < 0 || n > modCount
*/
public void add(int n, Object obj) {
if (n > modCount) throw new IndexOutOfBoundsException(n + " > " + modCount);
modCount++;
if (n > listItems.length) {
int cap = (int) Math.ceil(listItems.length * growthFactor);
SoftReference[] items = new SoftReference[cap];
System.arraycopy(listItems, 0, items, 0, listItems.length);
listItems = items;
}
listItems[n] = new SoftReference(obj, referenceQueue);
}
/**
* Describe <code>add</code> method here.
*
* @param obj an <code>Object</code> value
* @return <code>true</code>
*/
public boolean add(Object obj) {
add(modCount, obj);
return true;
}
/**
* Describe <code>set</code> method here.
*
* @param n an <code>int</code> value
* @param obj an <code>Object</code> value
* @return an <code>Object</code> value
* @exception IndexOutOfBoundException if n < 0 || n >= modCount
*/
public Object set(int n, Object obj) {
if (n >= modCount) throw new IndexOutOfBoundsException(n + " >= " + modCount);
final Object old = listItems[n].get();
listItems[n] = new SoftReference(obj, referenceQueue);
return old;
}
/**
* Describe <code>remove</code> method here.
*
* @param n an <code>int</code> value
* @return an <code>Object</code> value
* @exception IndexOutOfBoundException if n < 0 || n >= modCount
*/
public Object remove(int n) {
if (n >= modCount) throw new IndexOutOfBoundsException(n + " >= " + modCount);
modCount--;
final Object old = listItems[n].get();
System.arraycopy(listItems, n, listItems, n - 1, listItems.length - n);
return old;
}
/**
* Describe <code>removeRange</code> method here.
*
* @param from an <code>int</code> value
* @param to an <code>int</code> value
* @exception IndexOutOfBoundException if from < 0 || to >= modCount
* @exception IllegalArgumentException if from > to
*/
protected void removeRange(int from, int to) {
if (from > to) throw new IllegalArgumentException("removeRange(" + from + ", " + to + ")");
if (to >= modCount) throw new IndexOutOfBoundsException(to + " >= " + modCount);
final int n = to - from;
modCount -= n;
System.arraycopy(listItems, to, listItems, from, listItems.length - n);
}
} // CachedList
public class ChangeList extends CachedList implements ResourceList {
int changeNumber;
/**
* Gets the value of changeNumber
*
* @return the value of changeNumber
*/
public int getChangeNumber() {
return this.changeNumber;
}
/**
* Sets the value of changeNumber
*
* @param n Value to assign to this.changeNumber
*/
public void setChangeNumber(int n) {
this.changeNumber = n;
}
// Implementation of javax.wvcm.ResourceList
/**
* Locks all the resources on this list.
*
* @return a <code>ResourceList.ResponseIterator</code> value
*/
public ResourceList.ResponseIterator doControl() {
return null;
}
/**
* Submit all the resources on this list to the depot.
*
* @param keep a <code>boolean</code> flag
* @param fork a <code>boolean</code> flag
* @return a <code>ResourceList.ResponseIterator</code> value
*/
public ResourceList.ResponseIterator doCheckin(boolean keep, boolean fork)
{
return null;
}
/**
* Open or reopen all the resources on this list.
*
* @param fork a <code>boolean</code> flag
* @param acts a <code>List</code> of Activity objects
* @param create a <code>boolean</code> flag
* @param share a <code>boolean</code> flag
* @return a <code>ResourceList.ResponseIterator</code> value
*/
public ResourceList.ResponseIterator doCheckout(boolean fork, List acts, boolean create, boolean share)
{
return null;
}
/**
* Refresh all the resources on this list from the depot.
*
* @param pnl a <code>PropertyNameList</code> object
* @param force a <code>boolean</code> flag
* @return a <code>ResourceList.ResponseIterator</code> value
*/
public ResourceList.ResponseIterator doRefresh(PropertyNameList pnl, boolean force) {
return null;
}
/**
* Revert all the resources on this list.
*
* @return a <code>ResourceList.ResponseIterator</code> value
*/
public ResourceList.ResponseIterator doUncheckout() {
return null;
}
} // ChangeList
} // P4Provider
Rename c:\src\perforce\paul_krause\perforce\api\java\wcvm\com\perforce\wvcm\P4Provider.java To c:\src\perforce\paul_krause\perforce\api\java\wcvm\com\perforce\wvcm\P4.java