org.deckfour.xes.model.impl.XAttributeMapLazyImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SEWOL Show documentation
Show all versions of SEWOL Show documentation
SEWOL provides support for the handling of workflow traces. Specifically it allows to specify the shape and content of process traces in terms of entries representing the execution of a specific workflow activity. SEWOL also allows to write these traces on disk as a log file with the help of a special file writer for process logs. Currently it supports plain text, Petrify, MXML and XES log file types. In order to specify security-related context information, SEWOL provides access control models such as access control lists (ACL) and role-based access control models (RBAC). All types of models can be conveniently edited with the help of appropriate dialogs.
The newest version!
/*
* OpenXES
*
* The reference implementation of the XES meta-model for event
* log data management.
*
* Copyright (c) 2008 Christian W. Guenther ([email protected])
*
*
* LICENSE:
*
* This code is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
* EXEMPTION:
*
* The use of this software can also be conditionally licensed for
* other programs, which do not satisfy the specified conditions. This
* requires an exemption from the general license, which may be
* granted on a per-case basis.
*
* If you want to license the use of this software with a program
* incompatible with the LGPL, please contact the author for an
* exemption at the following email address:
* [email protected]
*
*/
package org.deckfour.xes.model.impl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.deckfour.xes.model.XAttribute;
import org.deckfour.xes.model.XAttributeMap;
/**
* Lazy implementation of the XAttributeMap interface.
*
* This implementation serves as a proxy for an XAttributeMapImpl instance,
* which is initially not present. Once the attribute map is to be filled
* with values, the true backing XAttributeMapImpl instance will be created
* on the fly, and used for storing and accessing data transparently.
*
* This lazy instantiation prevents lots of initializations of real
* attribute maps, since a large amount of attributes do not have
* any meta-attributes.
*
* This class is a generic, and can be parametrized with the actual
* implementation for the backing storage, which will then be instantiated
* on demand. Note that you will also have to pass the Class object of
* this implementation to the constructor, since this is required for
* instantiation (by Java).
*
* @author Christian W. Guenther ([email protected])
*
*/
public class XAttributeMapLazyImpl implements XAttributeMap {
/**
* Default empty entry set used for lazy operation.
*/
private static final Set> EMPTY_ENTRYSET
= Collections.unmodifiableSet(new HashSet>(0));
/**
* Default empty key set used for lazy operation.
*/
private static final Set EMPTY_KEYSET =
Collections.unmodifiableSet(new HashSet(0));
/**
* Default empty entries used for lazy operation.
*/
private static final Collection EMPTY_ENTRIES =
Collections.unmodifiableCollection(new ArrayList(0));
/**
* Class implementing the backing store; this is needed for initialization
* of generic classes, as of the Java language.
*/
private Class backingStoreClass;
/**
* Backing store, initialized lazily, i.e. on the fly.
*/
private T backingStore = null;
/**
* Creates a new lazy attribute map instance.
*
* @param implementingClass Class which should be used for
* instantiating the backing storage.
*/
public XAttributeMapLazyImpl(Class implementingClass) {
backingStoreClass = implementingClass;
backingStore = null;
}
/**
* Returns the class used for implementing the
* backing store.
*
* @return The class used for implementing the
* backing store.
*/
public Class getBackingStoreClass() {
return backingStoreClass;
}
/* (non-Javadoc)
* @see java.util.Map#clear()
*/
public synchronized void clear() {
backingStore = null;
}
/* (non-Javadoc)
* @see java.util.Map#containsKey(java.lang.Object)
*/
public synchronized boolean containsKey(Object key) {
if(backingStore != null) {
return backingStore.containsKey(key);
} else {
return false;
}
}
/* (non-Javadoc)
* @see java.util.Map#containsValue(java.lang.Object)
*/
public synchronized boolean containsValue(Object value) {
if(backingStore != null) {
return backingStore.containsValue(value);
} else {
return false;
}
}
/* (non-Javadoc)
* @see java.util.Map#entrySet()
*/
public synchronized Set> entrySet() {
if(backingStore != null) {
return backingStore.entrySet();
} else {
return EMPTY_ENTRYSET;
}
}
/* (non-Javadoc)
* @see java.util.Map#get(java.lang.Object)
*/
public synchronized XAttribute get(Object key) {
if(backingStore != null) {
return backingStore.get(key);
} else {
return null;
}
}
/* (non-Javadoc)
* @see java.util.Map#isEmpty()
*/
public synchronized boolean isEmpty() {
if(backingStore != null) {
return backingStore.isEmpty();
} else {
return true;
}
}
/* (non-Javadoc)
* @see java.util.Map#keySet()
*/
public synchronized Set keySet() {
if(backingStore != null) {
return backingStore.keySet();
} else {
return EMPTY_KEYSET;
}
}
/* (non-Javadoc)
* @see java.util.Map#put(java.lang.Object, java.lang.Object)
*/
public synchronized XAttribute put(String key, XAttribute value) {
if(backingStore == null) {
try {
backingStore = backingStoreClass.newInstance();
} catch (Exception e) {
// Fuckup
e.printStackTrace();
}
}
return backingStore.put(key, value);
}
/* (non-Javadoc)
* @see java.util.Map#putAll(java.util.Map)
*/
public synchronized void putAll(Map extends String, ? extends XAttribute> t) {
if(t.size() > 0) {
if(backingStore == null) {
try {
backingStore = backingStoreClass.newInstance();
} catch (Exception e) {
// Fuckup
e.printStackTrace();
}
}
backingStore.putAll(t);
}
}
/* (non-Javadoc)
* @see java.util.Map#remove(java.lang.Object)
*/
public synchronized XAttribute remove(Object key) {
if(backingStore != null) {
return backingStore.remove(key);
} else {
return null;
}
}
/* (non-Javadoc)
* @see java.util.Map#size()
*/
public synchronized int size() {
if(backingStore != null) {
return backingStore.size();
} else {
return 0;
}
}
/* (non-Javadoc)
* @see java.util.Map#values()
*/
public synchronized Collection values() {
if(backingStore != null) {
return backingStore.values();
} else {
return EMPTY_ENTRIES;
}
}
/**
* Creates a clone, i.e. deep copy, of this lazy attribute map.
*/
@SuppressWarnings("unchecked")
public Object clone() {
XAttributeMapLazyImpl clone;
try {
clone = (XAttributeMapLazyImpl)super.clone();
if(backingStore != null) {
clone.backingStore = (T)backingStore.clone();
}
return clone;
} catch (CloneNotSupportedException e) {
// Fuckup!
e.printStackTrace();
return null;
}
}
}