001 /* 002 * Copyright (C) 2011 eXo Platform SAS. 003 * 004 * This is free software; you can redistribute it and/or modify it 005 * under the terms of the GNU Lesser General Public License as 006 * 007 * published by the Free Software Foundation; either version 2.1 of 008 * the License, or (at your option) any later version. 009 * 010 * This software is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this software; if not, write to the Free 017 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 018 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 019 */ 020 021 package org.crsh.jcr.command; 022 023 import org.crsh.cmdline.spi.Value; 024 025 import java.util.Properties; 026 import java.util.StringTokenizer; 027 028 public class InitProperties extends Value { 029 030 031 public InitProperties(String string) throws NullPointerException { 032 super(string); 033 } 034 035 public Properties getProperties() { 036 Properties props = new Properties(); 037 StringTokenizer tokenizer = new StringTokenizer(getString(), ";", false); 038 while(tokenizer.hasMoreTokens()){ 039 String token = tokenizer.nextToken(); 040 if(token.contains("=")) { 041 String key = token.substring(0, token.indexOf('=')); 042 String value = token.substring(token.indexOf('=') + 1, token.length()); 043 props.put(key, value); 044 } 045 } 046 return props; 047 } 048 049 }