Return-Path: Delivered-To: apmail-jakarta-hivemind-cvs-archive@www.apache.org Received: (qmail 49851 invoked from network); 9 Jun 2004 14:48:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 9 Jun 2004 14:48:48 -0000 Received: (qmail 52821 invoked by uid 500); 9 Jun 2004 14:48:54 -0000 Delivered-To: apmail-jakarta-hivemind-cvs-archive@jakarta.apache.org Received: (qmail 52794 invoked by uid 500); 9 Jun 2004 14:48:53 -0000 Mailing-List: contact hivemind-cvs-help@jakarta.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: hivemind-dev@jakarta.apache.org Delivered-To: mailing list hivemind-cvs@jakarta.apache.org Received: (qmail 52773 invoked by uid 99); 9 Jun 2004 14:48:53 -0000 Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Wed, 09 Jun 2004 07:48:53 -0700 Received: (qmail 49756 invoked by uid 1616); 9 Jun 2004 14:48:40 -0000 Date: 9 Jun 2004 14:48:40 -0000 Message-ID: <20040609144840.49755.qmail@minotaur.apache.org> From: hlship@apache.org To: jakarta-hivemind-cvs@apache.org Subject: cvs commit: jakarta-hivemind/framework/src/java/org/apache/hivemind/schema/rules QualifiedIdTranslator.java IdListTranslator.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N hlship 2004/06/09 07:48:40 Added: framework/src/java/org/apache/hivemind/util IdUtils.java framework/src/java/org/apache/hivemind/schema/rules QualifiedIdTranslator.java IdListTranslator.java Log: Add two new translators: qualified-id and id-list. Revision Changes Path 1.1 jakarta-hivemind/framework/src/java/org/apache/hivemind/util/IdUtils.java Index: IdUtils.java =================================================================== // Copyright 2004 The Apache Software Foundation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package org.apache.hivemind.util; import org.apache.hivemind.HiveMind; /** * A collection of utilities for handling qualified and unqualified ids. * * @author Howard Lewis Ship */ public class IdUtils { /** * Returns a fully qualfied id. If the id contains a '.', then it * is returned unchanged. Otherwise, the module's id is prefixed (with a * seperator '.') and returned; */ public static String qualify(String moduleId, String id) { if (id.indexOf('.') > 0) return id; return moduleId + "." + id; } /** * Qualifies a list of interceptor service ids provided for an interceptor * contribution. The special value "*" is not qualified. */ public static String qualifyList(String sourceModuleId, String list) { if (HiveMind.isBlank(list) || list.equals("*")) return list; String[] items = StringUtils.split(list); for (int i = 0; i < items.length; i++) items[i] = qualify(sourceModuleId, items[i]); return StringUtils.join(items, ','); } } 1.1 jakarta-hivemind/framework/src/java/org/apache/hivemind/schema/rules/QualifiedIdTranslator.java Index: QualifiedIdTranslator.java =================================================================== // Copyright 2004 The Apache Software Foundation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package org.apache.hivemind.schema.rules; import org.apache.hivemind.internal.Module; import org.apache.hivemind.schema.Translator; import org.apache.hivemind.util.IdUtils; /** * A {@link org.apache.hivemind.schema.Translator} that acts as a wrapper around * the {@link org.apache.hivemind.util.IdUtils#qualify(String, String)} method. * * @author Howard Lewis Ship */ public class QualifiedIdTranslator implements Translator { /** * @returns null if the inputValue is null, otherwise, invokes * {@link IdUtils#qualify(String, String)}. */ public Object translate(Module contributingModule, Class propertyType, String inputValue) { if (inputValue == null) return null; return IdUtils.qualify(contributingModule.getModuleId(), inputValue); } } 1.1 jakarta-hivemind/framework/src/java/org/apache/hivemind/schema/rules/IdListTranslator.java Index: IdListTranslator.java =================================================================== // Copyright 2004 The Apache Software Foundation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package org.apache.hivemind.schema.rules; import org.apache.hivemind.internal.Module; import org.apache.hivemind.schema.Translator; import org.apache.hivemind.util.IdUtils; /** * A {@link org.apache.hivemind.schema.Translator} that acts as a wrapper * around {@link org.apache.hivemind.util.IdUtils#qualifyList(String, String)}. * * @author Howard Lewis Ship */ public class IdListTranslator implements Translator { public Object translate(Module contributingModule, Class propertyType, String inputValue) { if (inputValue == null) return null; return IdUtils.qualifyList(contributingModule.getModuleId(), inputValue); } } --------------------------------------------------------------------- To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org