|
[ source navigation ] [ diff markup ] [ identifier search ] [ general search ] |
|||||
|
||||||
001 /************************************************************************* 002 * 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * Copyright 2008 by Sun Microsystems, Inc. 006 * 007 * OpenOffice.org - a multi-platform office productivity suite 008 * 009 * $RCSfile: Converter.java,v $ 010 * $Revision: 1.3 $ 011 * 012 * This file is part of OpenOffice.org. 013 * 014 * OpenOffice.org is free software: you can redistribute it and/or modify 015 * it under the terms of the GNU Lesser General Public License version 3 016 * only, as published by the Free Software Foundation. 017 * 018 * OpenOffice.org is distributed in the hope that it will be useful, 019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 021 * GNU Lesser General Public License version 3 for more details 022 * (a copy is included in the LICENSE file that accompanied this code). 023 * 024 * You should have received a copy of the GNU Lesser General Public License 025 * version 3 along with OpenOffice.org. If not, see 026 * <http://www.openoffice.org/license.html> 027 * for a copy of the LGPLv3 License. 028 * 029 ************************************************************************/ 030 031 package org.openoffice.setup.Util; 032 033 import java.util.HashMap; 034 import java.util.Iterator; 035 import java.util.Map; 036 import java.util.Vector; 037 038 public class Converter { 039 040 private Converter() { 041 } 042 043 static public String[] convertHashmapToStringArray(HashMap map) { 044 045 int size = map.size(); 046 String[] myStringArray = new String[size]; 047 048 Iterator m = map.entrySet().iterator(); 049 int counter = 0; 050 051 while ( m.hasNext() ) { 052 Map.Entry entry = (Map.Entry) m.next(); 053 String env = entry.getKey() + "=" + entry.getValue(); 054 myStringArray[counter] = env; 055 counter = counter + 1; 056 } 057 058 return myStringArray; 059 } 060 061 static public HashMap convertVectorToHashmap(Vector vec) { 062 HashMap map = new HashMap(); 063 064 for (int i = 0; i < vec.size(); i++) { 065 String key = null; 066 String value = null; 067 068 String line = (String)vec.get(i); 069 int position = line.indexOf("="); 070 if ( position > -1 ) { 071 key = line.substring(0, position); 072 value = line.substring(position + 1, line.length()); 073 } else { 074 key = line; 075 value = null; 076 } 077 078 map.put(key, value); 079 } 080 081 return map; 082 } 083 084 static public Vector convertHashMapToVector(HashMap hash) { 085 Vector vec = new Vector(); 086 087 Iterator m = hash.entrySet().iterator(); 088 089 while ( m.hasNext() ) { 090 Map.Entry entry = (Map.Entry) m.next(); 091 String line = entry.getKey() + "=" + entry.getValue(); 092 vec.add(line); 093 } 094 095 return vec; 096 } 097 098 }
| [ source navigation ] | [ diff markup ] | [ identifier search ] | [ general search ] |
| This page was automatically generated by the LXR engine. The LXR team |
|