/* * GS2MacroResolver.java * Copyright (C) 2005 New Zealand Digital Library, http://www.nzdl.org * * 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 program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package org.greenstone.gsdl3.util; import java.util.ArrayList; public class GS2MacroResolver extends MacroResolver { protected GDBMWrapper gdbm_src = null; // need to make it not add macros if they are already present public GS2MacroResolver(GDBMWrapper gdbm) { super(); gdbm_src = gdbm; } public String resolve(String text, String lang, String scope, String doc_oid) { if (text == null || text.equals("")) return text; if (scope.equals(SCOPE_TEXT) && text_macros.size()==0) return text; if (scope.equals(SCOPE_META) && metadata_macros.size() ==0) return text; DBInfo node_info = null; DBInfo root_info = null; boolean new_lang = false; if (this.lang == null || !this.lang.equals(lang) ) { new_lang = true; this.lang = lang; } ArrayList macros; if (scope.equals(SCOPE_TEXT)) { macros = text_macros; } else { macros = metadata_macros; } for (int i=0; i