1 package org.apache.archiva.web.tags;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.taglibs.standard.tag.common.core.NullAttributeException;
23 import org.apache.taglibs.standard.tag.el.core.ExpressionUtil;
25 import javax.servlet.jsp.JspException;
26 import javax.servlet.jsp.PageContext;
27 import javax.servlet.jsp.tagext.Tag;
34 public class ExpressionTool
36 private PageContext pageContext;
40 private String tagName;
42 public ExpressionTool( PageContext pageContext, Tag tag, String tagName )
44 this.pageContext = pageContext;
46 this.tagName = tagName;
49 public boolean optionalBoolean( String propertyName, String expression, boolean defaultValue )
54 Boolean ret = (Boolean) ExpressionUtil.evalNotNull( this.tagName, propertyName, expression, Boolean.class,
55 this.tag, this.pageContext );
62 return ret.booleanValue();
64 catch ( NullAttributeException e )
70 public String optionalString( String propertyName, String expression, String defaultValue )
75 String ret = (String) ExpressionUtil.evalNotNull( this.tagName, propertyName, expression, String.class,
76 this.tag, this.pageContext );
85 catch ( NullAttributeException e )
91 public String requiredString( String propertyName, String expression )
96 String ret = (String) ExpressionUtil.evalNotNull( this.tagName, propertyName, expression, String.class,
97 this.tag, this.pageContext );
100 catch ( NullAttributeException e )
102 String emsg = "Required " + this.tagName + " property [" + propertyName + "] is null!";
105 throw new JspException( emsg );
109 private void log( String msg, Throwable t )
111 pageContext.getServletContext().log( msg, t );