当前位置: 首页>>代码示例>>Java>>正文


Java StripesFilter类代码示例

本文整理汇总了Java中net.sourceforge.stripes.controller.StripesFilter的典型用法代码示例。如果您正苦于以下问题:Java StripesFilter类的具体用法?Java StripesFilter怎么用?Java StripesFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StripesFilter类属于net.sourceforge.stripes.controller包,在下文中一共展示了StripesFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSingleItemTypeConverter

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
    * Fetches an instance of {@link TypeConverter} that can be used to convert the individual
    * items split out of the input String. By default uses the {@link TypeConverterFactory} to
    * find an appropriate {@link TypeConverter}.
    *
    * @param targetType the type that each item should be converted to.
    * @return a TypeConverter for use in converting each individual item.
    */
   @SuppressWarnings("unchecked")
protected TypeConverter getSingleItemTypeConverter(Class targetType) {
       try {
           TypeConverterFactory factory = StripesFilter.getConfiguration().getTypeConverterFactory();
           return factory.getTypeConverter(targetType, this.locale);
       }
       catch (Exception e) {
           throw new StripesRuntimeException(
                   "You are using the OneToManyTypeConverter to convert a String to a List of " +
                           "items for which there is no registered converter! Please check that the " +
                           "TypeConverterFactory knows how to make a converter for: " +
                           targetType, e
           );
       }
   }
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:24,代码来源:OneToManyTypeConverter.java

示例2: getValidationMetadata

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
protected ValidationMetadata getValidationMetadata() throws StripesJspException {
    // find the action bean class we're dealing with
    Class<? extends ActionBean> beanClass = getParentFormTag().getActionBeanClass();

    if (beanClass != null) {
        // ascend the tag stack until a tag name is found
        String name = getName();
        if (name == null) {
            InputTagSupport tag = getParentTag(InputTagSupport.class);
            while (name == null && tag != null) {
                name = tag.getName();
                tag = tag.getParentTag(InputTagSupport.class);
            }
        }

        // check validation for encryption flag
        return StripesFilter.getConfiguration().getValidationMetadataProvider()
                .getValidationMetadata(beanClass, new ParameterName(name));
    }
    else {
        return null;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:24,代码来源:InputTagSupport.java

示例3: format

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Attempts to format an object using the Stripes formatting system.  If no formatter can
 * be found, then a simple String.valueOf(input) will be returned.  If the value passed in
 * is null, then the empty string will be returned.
 * 
 * @param input The object to be formatted
 * @param forOutput If true, then the object will be formatted for output to the JSP. Currently,
 *            that means that if encryption is enabled for the ActionBean property with the same
 *            name as this tag then the formatted value will be encrypted before it is returned.
 */
@SuppressWarnings("unchecked")
protected String format(Object input, boolean forOutput) {
    if (input == null) {
        return "";
    }

    // format the value
    FormatterFactory factory = StripesFilter.getConfiguration().getFormatterFactory();
    Formatter formatter = factory.getFormatter(input.getClass(),
                                               getPageContext().getRequest().getLocale(),
                                               this.formatType,
                                               this.formatPattern);
    String formatted = (formatter == null) ? String.valueOf(input) : formatter.format(input);

    // encrypt the formatted value if required
    if (forOutput && formatted != null) {
        try {
            ValidationMetadata validate = getValidationMetadata();
            if (validate != null && validate.encrypted())
                formatted = CryptoUtil.encrypt(formatted);
        }
        catch (JspException e) {
            throw new StripesRuntimeException(e);
        }
    }

    return formatted;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:39,代码来源:InputTagSupport.java

示例4: format

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Attempts to format an object using an appropriate {@link Formatter}. If
 * no formatter is available for the object, then this method will call
 * <code>toString()</code> on the object. A null <code>value</code> will
 * be formatted as an empty string.
 * 
 * @param value
 *            the object to be formatted
 * @return the formatted value
 */
@SuppressWarnings("unchecked")
protected String format(Object value) {
    if (value == null)
        return "";

    FormatterFactory factory = StripesFilter.getConfiguration().getFormatterFactory();
    Formatter formatter = factory.getFormatter(value.getClass(),
                                               getPageContext().getRequest().getLocale(),
                                               this.formatType,
                                               this.formatPattern);
    if (formatter == null)
        return String.valueOf(value);
    else
        return formatter.format(value);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:26,代码来源:FormatTag.java

示例5: getKeyMaterialFromConfig

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Attempts to load material from which to manufacture a secret key from the Stripes
 * Configuration. If config is unavailable or there is no material configured null
 * will be returned.
 *
 * @return a byte[] of key material, or null
 */
protected static byte[] getKeyMaterialFromConfig() {
    try {
        Configuration config = StripesFilter.getConfiguration();
        if (config != null) {
            String key = config.getBootstrapPropertyResolver().getProperty(CONFIG_ENCRYPTION_KEY);
            if (key != null) {
                return key.getBytes();
            }
        }
    }
    catch (Exception e) {
        log.warn("Could not load key material from configuration.", e);
    }

    return null;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:24,代码来源:CryptoUtil.java

示例6: getDefaultValue

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
    * <p>Attempts to create a default value for a given node by either a) creating a new array
    * instance for arrays, b) fetching the first enum for enum classes, c) creating a default
    * instance for interfaces and abstract classes using ReflectUtil or d) calling a default
    * constructor.
    *
    * @param node the node for which to find a default value
    * @return an instance of the appropriate type
    * @throws EvaluationException if an instance cannot be created
    */
   @SuppressWarnings("unchecked")
private Object getDefaultValue(NodeEvaluation node) throws EvaluationException {
       try {
           Class clazz = convertToClass(node.getValueType(), node);

           if (clazz.isArray()) {
               return Array.newInstance(clazz.getComponentType(), 0);
           }
           else if (clazz.isEnum()) {
               return clazz.getEnumConstants()[0];
           }
           else {
               return StripesFilter.getConfiguration().getObjectFactory().newInstance(clazz);
           }
       }
       catch (Exception e) {
           throw new EvaluationException("Encountered an exception while trying to create " +
           " a default instance for property '" + node.getNode().getStringValue() + "' in " +
           "expression '" + this.expression.getSource() + "'.", e);
       }
   }
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:32,代码来源:PropertyExpressionEvaluation.java

示例7: getValidationMetadata

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Get a map of property names to {@link ValidationMetadata} for the {@link ActionBean} class
 * bound to the URL being built. If the URL does not point to an ActionBean class or no
 * validation metadata exists for the ActionBean class then an empty map will be returned.
 * 
 * @return a map of ActionBean property names to their validation metadata
 * @see ValidationMetadataProvider#getValidationMetadata(Class)
 */
protected Map<String, ValidationMetadata> getValidationMetadata() {
    Map<String, ValidationMetadata> validations = null;
    Configuration configuration = StripesFilter.getConfiguration();
    if (configuration != null) {
        Class<? extends ActionBean> beanType = null;
        try {
            beanType = configuration.getActionResolver().getActionBeanType(this.baseUrl);
        }
        catch (UrlBindingConflictException e) {
            // This can be safely ignored
        }

        if (beanType != null) {
            validations = configuration.getValidationMetadataProvider().getValidationMetadata(
                    beanType);
        }
    }

    if (validations == null)
        validations = Collections.emptyMap();

    return validations;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:32,代码来源:UrlBuilder.java

示例8: setupContext

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
@BeforeClass
public void setupContext() {
    context = new MockServletContext("waitpage");
    
    // Add the Stripes Filter
    Map<String,String> filterParams = new HashMap<String,String>();
    filterParams.put("CoreInterceptor.Classes",
            "org.stripesstuff.tests.waitpage.TestableWaitPageInterceptor," +
            "net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor," +
            "net.sourceforge.stripes.controller.HttpCacheInterceptor");
    filterParams.put("ActionResolver.Packages",
            "org.stripesstuff.tests.waitpage.action");
    context.addFilter(StripesFilter.class, "StripesFilter", filterParams);
    
    // Add the Stripes Dispatcher
    context.setServlet(DispatcherServlet.class, "StripesDispatcher", null);
}
 
开发者ID:StripesFramework,项目名称:stripes-stuff,代码行数:18,代码来源:WaitPageTest.java

示例9: testValidateTypeConverterExtendsStock

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Tests the use of an auto-loaded type converter versus a type converter explicitly configured
 * via {@code @Validate(converter)}, where the auto-loaded type converter extends the stock
 * type converter.
 *
 * @see http://www.stripesframework.org/jira/browse/STS-610
 */
@Test(groups="extensions")
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testValidateTypeConverterExtendsStock() throws Exception {
    MockRoundtrip trip = new MockRoundtrip(getMockServletContext(), getClass());
    Locale locale = trip.getRequest().getLocale();
    TypeConverterFactory factory = StripesFilter.getConfiguration().getTypeConverterFactory();
    TypeConverter<?> tc = factory.getTypeConverter(Integer.class, locale);
    try {
        factory.add(Integer.class, MyIntegerTypeConverter.class);
        trip.addParameter("shouldBeDoubled", "42");
        trip.addParameter("shouldNotBeDoubled", "42");
        trip.execute("validateTypeConverters");
        ValidationAnnotationsTest actionBean = trip.getActionBean(getClass());
        Assert.assertEquals(actionBean.shouldBeDoubled, new Integer(84));
        Assert.assertEquals(actionBean.shouldNotBeDoubled, new Integer(42));
    }
    finally {
        Class<? extends TypeConverter> tcType = tc == null ? null : tc.getClass();
        factory.add(Integer.class, (Class<? extends TypeConverter<?>>) tcType);
    }
}
 
开发者ID:scarcher2,项目名称:stripes,代码行数:29,代码来源:ValidationAnnotationsTest.java

示例10: testValidateTypeConverterDoesNotExtendStock

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Tests the use of an auto-loaded type converter versus a type converter explicitly configured
 * via {@code @Validate(converter)}, where the auto-loaded type converter does not extend the
 * stock type converter.
 *
 * @see http://www.stripesframework.org/jira/browse/STS-610
 */
@SuppressWarnings("unchecked")
@Test(groups="extensions")
public void testValidateTypeConverterDoesNotExtendStock() throws Exception {
    TypeConverterFactory factory = StripesFilter.getConfiguration().getTypeConverterFactory();
    Class<? extends TypeConverter> oldtc = factory.getTypeConverter(//
            String.class, Locale.getDefault()).getClass();
    try {
        MockRoundtrip trip = new MockRoundtrip(getMockServletContext(), getClass());
        factory.add(String.class, MyStringTypeConverter.class);
        trip.addParameter("shouldBeUpperCased", "test");
        trip.addParameter("shouldNotBeUpperCased", "test");
        trip.execute("validateTypeConverters");
        ValidationAnnotationsTest actionBean = trip.getActionBean(getClass());
        Assert.assertEquals(actionBean.shouldBeUpperCased, "TEST");
        Assert.assertEquals(actionBean.shouldNotBeUpperCased, "test");
    }
    finally {
        factory.add(String.class, (Class<? extends TypeConverter<?>>) oldtc);
    }
}
 
开发者ID:scarcher2,项目名称:stripes,代码行数:28,代码来源:ValidationAnnotationsTest.java

示例11: getMockServletContext

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
private MockServletContext getMockServletContext()
{
    MockServletContext ctx = new MockServletContext("test");

    // Add the Stripes Filter
    Map<String, String> filterParams = new HashMap<String, String>();
    filterParams.put("ActionResolver.Packages", "org.stripesrest");
    filterParams.put("Interceptor.Classes", "org.stripesrest.RestActionInterceptor");
    ctx.addFilter(StripesFilter.class, "StripesFilter", filterParams);

    // Add the Stripes Dispatcher
    ctx.setServlet(DispatcherServlet.class, "StripesDispatcher", null);
    
    return ctx;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:16,代码来源:RestActionBeanTest.java

示例12: getErrorMessage

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Looks up the specified key in the error message resource bundle. If the
 * bundle is missing or if the resource cannot be found, will return null
 * instead of throwing an exception.
 *
 * @param locale the locale in which to lookup the resource
 * @param key the exact resource key to lookup
 * @return the resource String or null
 */
public static String getErrorMessage(Locale locale, String key) {
    try {
        Configuration config = StripesFilter.getConfiguration();
        ResourceBundle bundle = config.getLocalizationBundleFactory().getErrorMessageBundle(locale);
        return bundle.getString(key);
    }
    catch (MissingResourceException mre) {
        return null;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:20,代码来源:LocalizationUtility.java

示例13: getActionResolver

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/** Find and return the {@link AnnotatedClassActionResolver} for the given context. */
private static AnnotatedClassActionResolver getActionResolver(MockServletContext context) {
    for (Filter filter : context.getFilters()) {
        if (filter instanceof StripesFilter) {
            ActionResolver resolver = ((StripesFilter) filter).getInstanceConfiguration()
                    .getActionResolver();
            if (resolver instanceof AnnotatedClassActionResolver) {
                return (AnnotatedClassActionResolver) resolver;
            }
        }
    }

    return null;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:15,代码来源:MockRoundtrip.java

示例14: getActionBeanUrl

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Similar to the {@link #getActionBeanType(Object)} method except that instead of
 * returning the Class of ActionBean it returns the URL Binding of the ActionBean.
 *
 * @param nameOrClass either the String FQN of an ActionBean class, or a Class object
 * @return the URL of the appropriate ActionBean class or null
 */
protected String getActionBeanUrl(Object nameOrClass) {
    Class<? extends ActionBean> beanType = getActionBeanType(nameOrClass);
    if (beanType != null) {
        return StripesFilter.getConfiguration().getActionResolver().getUrlBinding(beanType);
    }
    else {
        return null;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:17,代码来源:StripesTagSupport.java

示例15: setAction

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Sets the action for the form. If the form action begins with a slash, and does not already
 * contain the context path, then the context path of the web application will get prepended to
 * the action before it is set. In general actions should be specified as &quot;absolute&quot;
 * paths within the web application, therefore allowing them to function correctly regardless of
 * the address currently shown in the browser&apos;s address bar.
 * 
 * @param action the action path, relative to the root of the web application
 */
public void setAction(String action) {
    // Use the action resolver to figure out what the appropriate URL binding if for
    // this path and use that if there is one, otherwise just use the action passed in
    String binding = StripesFilter.getConfiguration().getActionResolver()
            .getUrlBindingFromPath(action);
    if (binding != null) {
        this.actionWithoutContext = binding;
    }
    else {
        this.actionWithoutContext = action;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:22,代码来源:FieldMetadataTag.java


注:本文中的net.sourceforge.stripes.controller.StripesFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。