org.apache.myfaces.trinidadinternal.ui.expl.UIImplicitObject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of trinidad-impl Show documentation
Show all versions of trinidad-impl Show documentation
Private implementation of the Apache MyFaces Trinidad project
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.trinidadinternal.ui.expl;
import java.util.Set;
import java.util.Map;
import java.util.List;
import java.util.AbstractMap;
import java.util.AbstractList;
import java.util.Collections;
import org.apache.myfaces.trinidad.logging.TrinidadLogger;
import org.apache.myfaces.trinidadinternal.ui.UIXRenderingContext;
import org.apache.myfaces.trinidadinternal.ui.AttributeKey;
import org.apache.myfaces.trinidadinternal.ui.data.DataObject;
import org.apache.myfaces.trinidadinternal.ui.data.DataObjectList;
import org.apache.myfaces.trinidadinternal.ui.data.DataSet;
import org.apache.myfaces.trinidadinternal.ui.data.MutableDataObject;
import org.apache.myfaces.trinidadinternal.ui.data.bean.BeanDOAdapter;
/**
* @version $Name: $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/ui/expl/UIImplicitObject.java#0 $) $Date: 10-nov-2005.18:56:28 $
* @deprecated This class comes from the old Java 1.2 UIX codebase and should not be used anymore.
*/
@Deprecated
public class UIImplicitObject
{
protected UIImplicitObject(UIVariableResolver varResolver)
{
_varResolver = varResolver;
}
/**
* Gets the VariableResolver
*/
public final UIVariableResolver getVariableResolver()
{
return _varResolver;
}
/**
* Gets the current RenderingContext.
*/
public final UIXRenderingContext getRenderingContext()
{
return _varResolver.getRenderingContext();
}
/**
* Gets the current data on the rendering context.
*/
public final Object getCurrent()
{
UIXRenderingContext context = getRenderingContext();
DataObject currentData = context.getCurrentDataObject();
return adapt(currentData);
}
/**
* Gets the data provider map from the rendering context.
*/
public final Object getData()
{
return _dataMap;
}
/**
* Gets the root attribute map.
*/
public final Object getRootAttr()
{
return _rootAttrsMap;
}
/**
* Gets a map of the support color palettes.
*/
public final Object getColorPalette()
{
return ColorPaletteUtils.getColorPaletteMap();
}
/**
* Converts some instance into a {@link Map} or {@link List}. The instances
* recognized by this method are {@link DataSet}, {@link DataObject} and
* {@link DataObjectList}
*/
public Object adapt(Object value)
{
if ((value==null) || (value instanceof List) || (value instanceof Map))
{
// no conversion necessary
return value;
}
else if (value instanceof BeanDOAdapter)
{
Object bean = ((BeanDOAdapter) value).selectValue(getRenderingContext(),
".");
if (bean != null)
return bean;
return new DataObjectMap((DataObject) value);
}
else if (value instanceof DataSet)
{
return new DataSetMap((DataSet) value);
}
else if (value instanceof DataObjectList)
{
// sometimes objects might implement both DataObject and DataObjectList
// but not DataSet:
if (value instanceof DataObject)
return new DataSetMap((DataObject) value, (DataObjectList) value);
else
return new DOLList((DataObjectList) value);
}
else if (value instanceof DataObject)
{
return new DataObjectMap((DataObject) value);
}
return value;
}
private final Map