All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.spardat.xma.mdl.util.TransStringSet Maven / Gradle / Ivy

/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

// @(#) $Id: TransStringSet.java 2089 2007-11-28 13:56:13Z s3460 $
package at.spardat.xma.mdl.util;

import java.io.IOException;

import at.spardat.xma.mdl.Synchronization;
import at.spardat.xma.mdl.Transactional;
import at.spardat.xma.serializer.XmaInput;
import at.spardat.xma.serializer.XmaOutput;

/**
 * This class technically is a set of Strings with the expanded capability 
 * to rollback changes made since particular points in the past. Therefore
 * the name 'transactional string set'. Basically, 
 * the states to which the state may be rollbacked are construction and
 * the last calls to commit or rollback.
 * 
 * @author YSD, 10.04.2003 09:59:53
 */
public abstract class TransStringSet implements Transactional, Synchronization, Descriptive {

    /**
     * Discards the history information. 
     */    
    public abstract void commit ();

    /**
     * Restores the state of this to the state of the last commit,
     * rollback or construction. 
     */    
    public abstract void rollback ();
    
    /**
     * Returns true if this selection set has changed since construction or
     * the last call to commit or rollback.
     */
    public abstract boolean changed ();
    
    /**
     * Adds a given key to the selection set. If the set is restricted in size
     * (which may be decided upon by the subclass), the add operation may
     * work like a replace in that an old element be removed from the set.
     * 
     * @param key the key to add; must not be null.
     * @return true if added, false if already in the set
     * @exception IllegalArgumentException if key is null.
     */
    public abstract boolean add (String key);
    
    /**
     * Removes a given key from the selection set
     * 
     * @param key the key to remove
     * @return true if removed, false if not in the set
     * @exception IllegalArgumentException if key is null.
     */
    public abstract boolean remove (String key);
    
    /**
     * Removes all entries from this.
     */
    public abstract void clear ();
    
    /**
     * Returns the number of strings in the set.
     */
    public abstract int size ();
    
    /**
     * Returns some String in this set or null if size() == 0.
     */
    public abstract String getSome ();
    
    /**
     * Returns a newly allocated String[] containing all Strings in this set.
     * The length of the returned array is size().  
     */
    public abstract String [] getAll ();
    
    /**
     * Returns true if this set contains the provided key
     */
    public abstract boolean contains (String key);
    
    /**
     * Estimates the number of bytes this object consumes in memory.
     */
    public abstract int estimateMemory ();
 
    /**
     * @see at.spardat.xma.mdl.Synchronization#externalize(at.spardat.xma.serializer.XmaOutput, boolean)
     */
    public abstract void externalize (XmaOutput xo, boolean forceFull) throws IOException;

    /**
     * @see at.spardat.xma.mdl.Synchronization#internalize(at.spardat.xma.serializer.XmaInput)
     */
    public abstract void internalize (XmaInput in) throws IOException, ClassNotFoundException;

    /**
     * @see at.spardat.xma.mdl.util.Descriptive#describe(at.spardat.xma.mdl.util.DNode)
     */
    public abstract void describe (DNode node);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy