it.tidalwave.mobile.media.Media Maven / Gradle / Ivy
The 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://java.net/hg/bluebill~core-src
*
**********************************************************************************************************************/
package it.tidalwave.mobile.media;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.openide.util.Lookup;
import it.tidalwave.util.As;
import it.tidalwave.util.AsException;
import it.tidalwave.util.Id;
import it.tidalwave.util.Key;
import it.tidalwave.util.NotFoundException;
import it.tidalwave.util.TypeSafeMap;
import it.tidalwave.util.TypeSafeHashMap;
import it.tidalwave.role.spi.DefaultIdentifiable;
import it.tidalwave.role.Identifiable;
import it.tidalwave.role.Removable;
import it.tidalwave.mobile.util.Downloadable;
import it.tidalwave.mobile.util.DefaultDownloadable;
import it.tidalwave.netbeans.util.AsLookupSupport;
import it.tidalwave.semantic.GenericEntity;
import it.tidalwave.semantic.vocabulary.DublinCoreVocabulary;
/***********************************************************************************************************************
*
* FIXME: refactor over EntityWithProperties!
*
* @author Fabrizio Giudici
* @version $Id$
*
**********************************************************************************************************************/
@Immutable
public class Media extends AsLookupSupport implements As, Lookup.Provider
{
public static final Class Media = Media.class;
private final static long serialVersionUID = 876756656347568673L;
private static final Logger log = LoggerFactory.getLogger(Media.class);
public static final Key AUTHOR = new Key(DublinCoreVocabulary.ID_DC_CREATOR);
public static final Key SOURCE = new Key(DublinCoreVocabulary.ID_DC_PUBLISHER);
public static final Key TITLE = new Key(DublinCoreVocabulary.ID_DC_TITLE);
public static final Key DATE = new Key(DublinCoreVocabulary.ID_DC_DATE);
public static final Key ID = new Key(DublinCoreVocabulary.ID_DC_IDENTIFIER);
public static final Key RIGHTS = new Key(DublinCoreVocabulary.ID_DC_RIGHTS);
public static final Key FORMAT = new Key(DublinCoreVocabulary.ID_DC_FORMAT);
public static final Key TYPE = new Key(DublinCoreVocabulary.ID_DC_TYPE);
// FIXME: remove, use standard vocabularies.
public static final String XX = "urn:bluebill-mobile:";
public static final Key RES_URL = new Key(XX + "url");
public static final Key MIME_TYPE = new Key(XX + "mime-type");
public static final Key DURATION = new Key(XX + "duration");
@Nonnull
private final TypeSafeMap propertyMap;
@CheckForNull
private Downloadable downloadable;
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
public Media()
{
this(Collections., Object>emptyMap());
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
private Media (final @Nonnull Map, Object> propertyMap)
{
this.propertyMap = new TypeSafeHashMap(propertyMap);
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
public T get (final @Nonnull Key key)
throws NotFoundException
{
return propertyMap.get(key);
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
public boolean contains (final @Nonnull Key> item)
{
return propertyMap.containsKey(item);
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
public Set> getKeys()
{
return propertyMap.getKeys();
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnegative
public int getSize()
{
return propertyMap.getSize();
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
public Iterator
© 2015 - 2025 Weber Informatics LLC | Privacy Policy