📄 vo.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
* are Copyright (C) 1999-2005 Jorg Janke.
* All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.model;
import java.io.*;
import java.util.*;
/**
* Value Object
*
* @author Jorg Janke
* @version $Id: VO.java,v 1.2 2006/01/28 02:09:09 jjanke Exp $
*/
public class VO
implements Map, Serializable
{
/**
* Constructor
*/
public VO ()
{
super ();
} // VO
// private static final long serialVersionUID = 8683452581122892189L;
/** Keys */
private ArrayList<String> m_keys = new ArrayList<String>();
/** Values */
private ArrayList<String> m_values = new ArrayList<String>();
/**
* Get Size
* @return size
*/
public int size ()
{
return m_keys.size();
} // size
/**
* Is Empty
* @return true if empty
*/
public boolean isEmpty ()
{
return m_keys.isEmpty();
} // isEmpty
/**
* Contains Key
* @param key key
* @return true if contains
*/
public boolean containsKey (Object key)
{
if (key == null)
return false;
return m_keys.contains(key);
} // containsKey
/**
* Contains Value
* @param value value
* @return true if contains value
*/
public boolean containsValue (Object value)
{
if (value == null)
return false;
return m_values.contains(value);
} // containsValue
/**
* Get Value with Key
* @param key key
* @return value or null
*/
public synchronized Object get (Object key)
{
if (key == null)
return null;
int index = m_keys.indexOf(key);
if (index != -1)
return m_values.get(index);
return null;
} // get
/**
* Put key/value
* @param key key
* @param value value
* @return previous value or null
*/
public synchronized Object put (Object key, Object value)
{
if (key == null)
return null;
if (value == null)
return remove(key);
//
String stringKey = key.toString();
String stringValue = value.toString();
int index = m_keys.indexOf(key);
if (index != -1)
return m_values.set (index, stringValue);
m_values.add(stringKey);
m_values.add(stringValue);
return null;
} // put
/**
* Remove
* @param key key
* @return previous value or null
*/
public synchronized Object remove (Object key)
{
if (key == null)
return null;
int index = m_keys.indexOf(key);
Object old = null;
if (index != -1)
{
old = m_values.get(index);
m_keys.remove(index);
m_values.remove(index);
}
return old;
} // remove
/**
* Put All
* @param t map
*/
public void putAll (Map t)
{
Iterator it = t.keySet().iterator();
while (it.hasNext())
{
Object key = it.next();
Object value = t.get(key);
put(key, value);
}
} // putAll
/**
* Clear keys/values
*/
public void clear ()
{
m_keys.clear();
m_values.clear();
} // clear
/**
* Get Key Set
* @return key set
*/
public Set<String> keySet ()
{
HashSet<String> set = new HashSet<String>(m_keys);
return set;
} // keySet
public Collection values ()
{
return m_values;
} // values
/**
* Get Values Set
* @return values set
*/
public Set<String> entrySet ()
{
HashSet<String> set = new HashSet<String>(m_values);
return set;
} // entrySet
} // VO
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -