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

org.apache.myfaces.trinidad.webapp.StringArrayValueExpression Maven / Gradle / Ivy

The newest version!
/*
 * 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.myfaces.trinidad.webapp;

import java.io.Serializable;

import javax.el.ELContext;
import javax.el.ValueExpression;

/**
 * Value expression to coerce String to String[] by splitting on whitespace.
 */
class StringArrayValueExpression
  extends ValueExpression
  implements Serializable
{
  public StringArrayValueExpression(
    ValueExpression wrapped)
  {
    _wrapped = wrapped;
  }

  @Override
  public Object getValue(ELContext context)
  {
    Object value = _wrapped.getValue(context);

    if (value instanceof String)
    {
      return TagUtils.parseNameTokens(value);
    }

    return value;
  }

  @Override
  public void setValue(ELContext context, Object value)
  {
    _wrapped.setValue(context, value);
  }

  @Override
  public boolean isReadOnly(ELContext context)
  {
    return _wrapped.isReadOnly(context);
  }

  @Override
  public Class getType(ELContext context)
  {
    return _wrapped.getType(context);
  }

  @Override
  public Class getExpectedType()
  {
    return _wrapped.getExpectedType();
  }

  @Override
  public String getExpressionString()
  {
    return _wrapped.getExpressionString();
  }

  @Override
  public boolean equals(Object obj)
  {
    return obj == this ||
           (obj instanceof StringArrayValueExpression &&
            ((StringArrayValueExpression)obj).getExpressionString().equals(getExpressionString()));
  }

  @Override
  public int hashCode()
  {
    return _wrapped.hashCode();
  }

  @Override
  public boolean isLiteralText()
  {
    return _wrapped.isLiteralText();
  }

  @SuppressWarnings("compatibility:-2817575277544016450")
  private static final long serialVersionUID = 1L;

  private final ValueExpression _wrapped;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy