public class OpenGraph extends Object
Modifier and Type | Field and Description |
---|---|
static Hashtable<String,String[]> |
BASE_TYPES |
static String[] |
REQUIRED_META |
Constructor and Description |
---|
OpenGraph()
Create an open graph representation for generating your own Open Graph object
|
OpenGraph(String url,
boolean ignoreSpecErrors,
URLConnection siteConnection)
Fetch the open graph representation from a web site
|
Modifier and Type | Method and Description |
---|---|
Hashtable<String,ArrayList<MetaElement>> |
exposeTable()
Obtain the underlying HashTable
|
String |
getBaseType()
Get the basic type of the Open graph page as per the specification
|
static Charset |
getConnectionCharset(URLConnection connection)
Gets the charset for specified connection.
|
String |
getContent(String property)
Get a value of a given Open Graph property
|
String |
getOriginalUrl()
Get the original URL the Open Graph page was obtained from
|
MetaElement[] |
getProperties()
Get all the defined properties of the Open Graph object
|
MetaElement[] |
getProperties(String property)
Get all the defined properties of the Open Graph object
|
boolean |
hasChanged()
Test if the object has been modified by setters/deleters.
|
boolean |
isFromWeb()
Test if the Open Graph object was initially a representation of a web page
|
void |
removeProperty(String property)
Removed a defined property
|
void |
setProperty(OpenGraphNamespace namespace,
String property,
String content)
Set the Open Graph property to a specific value
|
String[] |
toHTML()
Get the HTML representation of the Open Graph data.
|
String[] |
toXHTML()
Get the XHTML representation of the Open Graph data.
|
public static final String[] REQUIRED_META
public OpenGraph()
public OpenGraph(String url, boolean ignoreSpecErrors, URLConnection siteConnection) throws IOException, Exception
url
- The address to the web page to fetch Open Graph dataignoreSpecErrors
- Set this option to true if you don't wish to have an exception throw if the page does not conform to the basic 4 attributesIOException
- If a network error occurs, the HTML parser will throw an IO ExceptionException
- A generic exception is throw if the specific page fails to conform to the basic Open Graph standard as define by the constant REQUIRED_METApublic static Charset getConnectionCharset(URLConnection connection)
connection
- the connection.public String getBaseType()
public String getContent(String property)
property
- The Open graph property keypublic MetaElement[] getProperties()
public MetaElement[] getProperties(String property)
property
- The property to focus onpublic String getOriginalUrl()
public String[] toHTML()
public String[] toXHTML()
public void setProperty(OpenGraphNamespace namespace, String property, String content)
namespace
- The OpenGraph namespace the content belongs toproperty
- The og:XXXX where XXXX is the property you wish to setcontent
- The value or contents of the property to be setpublic void removeProperty(String property)
property
- The og:XXXX where XXXX is the property you wish to removepublic Hashtable<String,ArrayList<MetaElement>> exposeTable()
public boolean isFromWeb()
public boolean hasChanged()
Copyright © 2015. All Rights Reserved.