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

it.tidalwave.bluebill.taxonomy.elmo.impl.Support Maven / Gradle / Ivy

There is a newer version: 1.0.22
Show newest version
/***********************************************************************************************************************
 *
 * blueBill Core - open source birding
 * Copyright (C) 2009-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
 *
 ***********************************************************************************************************************
 *
 * Licensed 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.
 *
 ***********************************************************************************************************************
 *
 * WWW: http://bluebill.tidalwave.it
 * SCM: https://kenai.com/hg/bluebill~core-src
 *
 **********************************************************************************************************************/
package it.tidalwave.bluebill.taxonomy.elmo.impl;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import java.util.Locale;
import java.util.Map;
import java.util.SortedSet;
import org.openide.util.Lookup;
import org.openrdf.elmo.Entity;
import it.tidalwave.util.As.NotFoundBehaviour;
import it.tidalwave.openrdf.elmo.ElmoAsSupport;
import it.tidalwave.openrdf.elmo.ElmoUtils;
import it.tidalwave.openrdf.elmo.ElmoVolatile;
import it.tidalwave.openrdf.elmo.RDFUtils;

/*******************************************************************************
 *
 * @author  Fabrizio Giudici
 * @version $Id$
 *
 ******************************************************************************/
public class Support
  {
    @CheckForNull @ElmoVolatile
    private Lookup lookup;

    @Nonnull
    protected final Entity entity;

//    public Support()
//      {
//        entity = null;
//      }

    /*******************************************************************************************************************
     *
     *
     ******************************************************************************************************************/
    protected Support (final @Nonnull Entity entity)
      {
        this.entity = entity;
      }

    /*******************************************************************************************************************
     *
     * {@inheritDoc}
     *
     ******************************************************************************************************************/
    @Nonnull
    public  T as (final @Nonnull Class clazz)
      {
        return ElmoAsSupport.as(entity, clazz); // FIXME
//        return getLookup().lookup(As.class);.as(clazz);
      }

    /*******************************************************************************************************************
     *
     * {@inheritDoc}
     *
     ******************************************************************************************************************/
    @Nonnull
    public  T as (final @Nonnull Class clazz, final @Nonnull NotFoundBehaviour notFoundBehaviour)
      {
        return ElmoAsSupport.as(entity, clazz, notFoundBehaviour); // FIXME
//        return getLookup().lookup(As.class).as(clazz, notFoundBehaviour);
      }

    /*******************************************************************************************************************
     *
     * {@inheritDoc}
     *
     ******************************************************************************************************************/
    @Nonnull
    public String getDisplayName()
      {
        return RDFUtils.getDisplayName(entity);
      }

    /*******************************************************************************************************************
     *
     * {@inheritDoc}
     *
     ******************************************************************************************************************/
    @Nonnull
    public String getDisplayName (final @Nonnull Locale locale)
      {
        return RDFUtils.getDisplayName(entity, locale);
      }

    /*******************************************************************************************************************
     *
     * {@inheritDoc}
     *
     ******************************************************************************************************************/
    @Nonnull
    public SortedSet getLocales()
      {
        return RDFUtils.getLocales(entity);
      }

    /*******************************************************************************************************************
     *
     * {@inheritDoc}
     *
     ******************************************************************************************************************/
    @Nonnull
    public Map getDisplayNames()
      {
        throw new UnsupportedOperationException("Not supported yet.");
      }
    
    /*******************************************************************************************************************
     *
     * {@inheritDoc}
     *
     ******************************************************************************************************************/
    @Nonnull
    public synchronized Lookup getLookup()
      {
        if (lookup == null)
          {
            lookup = ElmoUtils.createLookup(entity, this);
          }

        return lookup;
      }
  }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy