INTEGRATION: CWS scriptingf5 (1.1.2); FILE ADDED

2004/02/25 18:37:52 npower 1.1.2.1: #i25272# Added a container implementation ( new com/sun/star/script/framework/container defined ) to better seperate Browse functionality from
io and script registry.

new abstract class to represent a parcel container, specific instances e.g.
ApplicationParcelContainer and DocumentParcelContainer extend this class
This commit is contained in:
Sander Vesik
2004-04-19 22:06:02 +00:00
parent ccf88f788e
commit e7cd1f2b71

View File

@@ -0,0 +1,102 @@
package com.sun.star.script.framework.container;
import com.sun.star.script.framework.log.*;
import com.sun.star.container.*;
import com.sun.star.uno.Type;
import com.sun.star.lang.*;
import com.sun.star.frame.*;
import java.io.*;
import java.util.*;
abstract public class ParcelContainer implements XNameAccess
{
protected String language;
protected String locationMacro;
protected Collection parcels = new ArrayList(4);
protected SFMacroHelper expander;
public ParcelContainer( SFMacroHelper expander, String language )
{
this.expander = expander;
this.language = language;
}
public Object getByName( String aName ) throws com.sun.star.container.NoSuchElementException, WrappedTargetException
{
Parcel parcel = null;
try
{
if ( hasElements() )
{
Iterator iter = parcels.iterator();
while ( iter.hasNext() )
{
Parcel parcelToCheck = (Parcel)iter.next();
if ( parcelToCheck.getName().equals( aName ) )
{
parcel = parcelToCheck;
break;
}
}
}
}
catch ( Exception e)
{
throw new WrappedTargetException( e.toString() );
}
if ( parcel == null )
{
throw new com.sun.star.container.NoSuchElementException( aName );
}
return parcel;
}
public String[] getElementNames()
{
if ( hasElements() )
{
Parcel[] theParcels = (Parcel[])parcels.toArray( new Parcel[0] );
String[] names = new String[ theParcels.length ];
for ( int count = 0; count < names.length; count++ )
{
names[count] = theParcels[ count ].getName();
}
return names;
}
return new String[0];
}
public boolean hasByName( String aName )
{
boolean isFound = false;
try
{
if ( getByName( aName ) != null )
{
isFound = true;
}
}
catch ( Exception e )
{
//TODO - handle trace
}
return isFound;
}
public Type getElementType()
{
return new Type();
}
public boolean hasElements()
{
if ( parcels == null || parcels.isEmpty() )
{
return false;
}
return true;
}
public abstract XNameContainer createParcel(String name) throws ElementExistException, com.sun.star.lang.WrappedTargetException;
public abstract boolean deleteParcel(String name) throws com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException;
public abstract String getRootPath();
public String getLanguage() { return language; }
}