alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Struts example source code file (MockTag.java)

This example Struts source code file (MockTag.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Struts tags/keywords

calendar, calendar, date, date, double, float, hashmap, integer, jsp, long, mocktag, mocktag, object, servlet, string, string, util

The Struts MockTag.java source code

/*
 * $Id: MockTag.java 651946 2008-04-27 13:41:38Z apetrelli $
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.struts2.views.jsp.ui;

import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.jsp.tagext.BodyTagSupport;


/**
 */
public class MockTag extends BodyTagSupport {

    private static final long serialVersionUID = 2694367759647164641L;

    private static String s;
    private static Integer i;
    private static Double d;
    private static Long l;
    private static Float f;
    private static Date date;
    private static Calendar cal;
    private static HashMap params;
    private static MockTag instance = new MockTag();


    public static MockTag getInstance() {
        return instance;
    }

    public void setCal(Calendar cal) {
        MockTag.cal = cal;
    }

    public Calendar getCal() {
        return cal;
    }

    public void setDate(Date date) {
        MockTag.date = date;
    }

    public Date getDate() {
        return date;
    }

    public void setDouble(Double d) {
        MockTag.d = d;
    }

    public Double getDouble() {
        return d;
    }

    public void setFloat(Float f) {
        MockTag.f = f;
    }

    public Float getFloat() {
        return f;
    }

    public void setInteger(Integer i) {
        MockTag.i = i;
    }

    public Integer getInteger() {
        return i;
    }

    public void setLong(Long l) {
        MockTag.l = l;
    }

    public Long getLong() {
        return l;
    }

    public Map getParameters() {
        return MockTag.params;
    }

    public void setString(String s) {
        MockTag.s = s;
    }

    public String getString() {
        return s;
    }

    public void addParameter(String key, Object value) {
        MockTag.params.put(key, value);
    }

    /**
     * resets all the static variables to their initial state.  this must be called before each test!
     */
    public void reset() {
        s = null;
        i = null;
        l = null;
        f = null;
        date = null;
        cal = null;
        params = new HashMap();
    }
}

Other Struts examples (source code examples)

Here is a short list of links related to this Struts MockTag.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.