
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@11 f0f2a975-2e09-46c8-9428-3b39399b9f3c
99 lines
3 KiB
Java
99 lines
3 KiB
Java
/************************************************************************
|
|
*
|
|
* StyleMap.java
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
*
|
|
* This library 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 library; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
* MA 02111-1307 USA
|
|
*
|
|
* Copyright: 2002-2007 by Henrik Just
|
|
*
|
|
* All Rights Reserved.
|
|
*
|
|
* Version 1.0 (2007-07-30)
|
|
*
|
|
*/
|
|
|
|
package writer2latex.latex.util;
|
|
|
|
import java.util.Hashtable;
|
|
import java.util.Enumeration;
|
|
|
|
public class StyleMap {
|
|
private Hashtable<String, StyleMapItem> items = new Hashtable<String, StyleMapItem>();
|
|
|
|
public void put(String sName, String sBefore, String sAfter, boolean bLineBreak, boolean bVerbatim) {
|
|
StyleMapItem item = new StyleMapItem();
|
|
item.sBefore = sBefore;
|
|
item.sAfter = sAfter;
|
|
item.sNext = ";;";
|
|
item.bLineBreak = bLineBreak;
|
|
item.bVerbatim = bVerbatim;
|
|
items.put(sName,item);
|
|
}
|
|
|
|
public void put(String sName, String sBefore, String sAfter, String sNext, boolean bVerbatim) {
|
|
StyleMapItem item = new StyleMapItem();
|
|
item.sBefore = sBefore;
|
|
item.sAfter = sAfter;
|
|
item.sNext = ";"+sNext+";";
|
|
item.bLineBreak = true;
|
|
item.bVerbatim = bVerbatim;
|
|
items.put(sName,item);
|
|
}
|
|
|
|
public void put(String sName, String sBefore, String sAfter) {
|
|
StyleMapItem item = new StyleMapItem();
|
|
item.sBefore = sBefore;
|
|
item.sAfter = sAfter;
|
|
item.sNext = ";;";
|
|
item.bLineBreak = true;
|
|
item.bVerbatim = false;
|
|
items.put(sName,item);
|
|
}
|
|
|
|
public boolean contains(String sName) {
|
|
return sName!=null && items.containsKey(sName);
|
|
}
|
|
|
|
public String getBefore(String sName) {
|
|
return items.get(sName).sBefore;
|
|
}
|
|
|
|
public String getAfter(String sName) {
|
|
return items.get(sName).sAfter;
|
|
}
|
|
|
|
public String getNext(String sName) {
|
|
String sNext = items.get(sName).sNext;
|
|
return sNext.substring(1,sNext.length()-1);
|
|
}
|
|
|
|
public boolean isNext(String sName, String sNext) {
|
|
String sNext1 = items.get(sName).sNext;
|
|
return sNext1.indexOf(";"+sNext+";")>-1;
|
|
}
|
|
|
|
public boolean getLineBreak(String sName) {
|
|
return contains(sName) && items.get(sName).bLineBreak;
|
|
}
|
|
|
|
public boolean getVerbatim(String sName) {
|
|
return contains(sName) && items.get(sName).bVerbatim;
|
|
}
|
|
|
|
public Enumeration<String> getNames() {
|
|
return items.keys();
|
|
}
|
|
|
|
}
|