All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.opensymphony.xwork2.config.impl.LocatableConstantFactory Maven / Gradle / Ivy

Go to download

XWork is an command-pattern framework that is used to power WebWork as well as other applications. XWork provides an Inversion of Control container, a powerful expression language, data type conversion, validation, and pluggable configuration.

The newest version!
/**
 * 
 */
package com.opensymphony.xwork2.config.impl;

import com.opensymphony.xwork2.inject.Context;
import com.opensymphony.xwork2.inject.Factory;
import com.opensymphony.xwork2.util.location.Located;
import com.opensymphony.xwork2.util.location.LocationUtils;

/**
 * Factory that remembers where a constant came from
 */
public class LocatableConstantFactory extends Located implements Factory {
    T constant;
    public LocatableConstantFactory(T constant, Object location) {
        this.constant = constant;
        setLocation(LocationUtils.getLocation(location));
    }
    
    public T create(Context ignored) {
        return constant;
    }
    
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(super.toString());
        sb.append(" defined at ");
        sb.append(getLocation().toString());
        return sb.toString();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy