Here you can find the source of Add(Vector
Parameter | Description |
---|---|
V | The current Vector or null( an empty vector will be created) |
S1 | The attribute name |
S2 | The corresponding attribute value(or null means the attribute must be absent) |
S3 | Used to describe * type matching. Not used yet.Can be null. |
public static Vector<String[]> Add(Vector<String[]> V, String S1, String S2, String S3)
//package com.java2s; /* /* ww w. j a v a 2 s . com*/ * File: UtilSm.java * * Copyright (C) 2010, Ruth Mikkelson * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * Contact : Ruth Mikkelson <mikkelsonr@uwstout.edu> * Department of Mathematics, Statistics and Computer Science * University of Wisconsin-Stout * Menomonie, WI 54751, USA * * This work was supported by the Spallation Neutron Source Division * of Oak Ridge National Laboratory, Oak Ridge, TN, USA. * * Last Modified: * * $Author:$ * $Date:$ * $Rev:$ */ import java.util.*; public class Main { /** * Used to create the Vector of attribute keys and corresponding values in * one statement. * * @param V The current Vector or null( an empty vector will be created) * * @param S1 The attribute name * * @param S2 The corresponding attribute value(or null means the attribute * must be absent) * * @param S3 Used to describe * type matching. Not used yet.Can be null. * * @return The new vector with the new information appended to it. */ public static Vector<String[]> Add(Vector<String[]> V, String S1, String S2, String S3) { if (V == null) V = new Vector<String[]>(); int n = 1; if (S1 == null) return V; if (S2 != null) n++; if (S3 != null && S2 != null) n++; String[] S = new String[n]; S[0] = S1; if (n > 1) S[1] = S2; if (n > 2) S[2] = S3; V.addElement(S); return V; } }