org.apache.any23.extractor.microdata
Class ItemPropValue
java.lang.Object
org.apache.any23.extractor.microdata.ItemPropValue
public class ItemPropValue
- extends Object
Describes a possible value for a Microdata item property.
- Author:
- Michele Mostarda (mostarda@fbk.eu)
ItemPropValue
public ItemPropValue(Object content,
ItemPropValue.Type type)
- Constructor.
- Parameters:
content
- content object.type
- content type.
parseDateTime
public static Date parseDateTime(String dateStr)
throws ParseException
- Throws:
ParseException
formatDateTime
public static String formatDateTime(Date in)
getContent
public Object getContent()
- Returns:
- the content object.
getType
public ItemPropValue.Type getType()
- Returns:
- the content type.
isPlain
public boolean isPlain()
- Returns:
true
if type is plain text.
isLink
public boolean isLink()
- Returns:
true
if type is a link.
isDate
public boolean isDate()
- Returns:
true
if type is a date.
isNested
public boolean isNested()
- Returns:
true
if type is a nested ItemScope
.
isInteger
public boolean isInteger()
- Returns:
true
if type is an integer.
isFloat
public boolean isFloat()
- Returns:
true
if type is a float.
isNumber
public boolean isNumber()
- Returns:
true
if type is a number.
getAsInteger
public int getAsInteger()
- Returns:
- the content value as integer, or raises an exception.
- Throws:
NumberFormatException
- if the content is not an integer.
ClassCastException
- if content is not plain.
getAsFloat
public float getAsFloat()
- Returns:
- the content value as float, or raises an exception.
- Throws:
NumberFormatException
- if the content is not an float.
ClassCastException
- if content is not plain.
getAsDate
public Date getAsDate()
- Returns:
- the content as
Date
if type == Type.DateTime
,
- Throws:
ClassCastException
- if content is not a valid date.
getAsLink
public URL getAsLink()
- Returns:
- the content value as URL, or raises an exception.
- Throws:
MalformedURLException
- if the content is not a valid URL.
ClassCastException
- if content is not a link.
getAsNested
public ItemScope getAsNested()
- Returns:
- the content value as
ItemScope
.
- Throws:
ClassCastException
- if the content is not a valid nested item.
toJSON
public String toJSON()
toString
public String toString()
- Overrides:
toString
in class Object
hashCode
public int hashCode()
- Overrides:
hashCode
in class Object
equals
public boolean equals(Object obj)
- Overrides:
equals
in class Object
Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.