Created
March 15, 2011 12:18
-
-
Save dizz/870656 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Result: | |
Result: {occi.attributes=[], occi.categories=[[{occi.core.scheme=http://schemas.ogf.org/occi/infrastructure/compute/action#, occi.core.class=action, occi.core.term=start, occi.core.title=Start Compute Action}], [{occi.core.scheme=http://schemas.ogf.org/occi/infrastructure/compute/action#, occi.core.class=action, occi.core.term=stop, occi.core.attributes=acpioff graceful poweroff, occi.core.title=Stop Compute Action}], [{occi.core.scheme=http://schemas.ogf.org/occi/infrastructure/compute/action#, occi.core.class=action, occi.core.term=restart, occi.core.attributes=warm graceful cold, occi.core.title=Restart Compute Action}], [{occi.core.scheme=http://schemas.ogf.org/occi/infrastructure/compute/action#, occi.core.class=action, occi.core.term=suspend, occi.core.attributes=hibernate suspend, occi.core.title=Suspend Compute Action}], [{occi.core.scheme=http://schemas.ogf.org/occi/infrastructure/network/action#, occi.core.class=action, occi.core.term=up, occi.core.title=Up Network Action}], [{occi.core.scheme=http://schemas.ogf.org/occi/infrastructure/network/action#, occi.core.class=action, occi.core.term=down, occi.core.title=Down Network Action}], [{occi.core.scheme=http://schemas.ogf.org/occi/infrastructure/storage/action#, occi.core.class=action, occi.core.term=online, occi.core.title=Online Storage Action}], [{occi.core.scheme=http://schemas.ogf.org/occi/infrastructure/storage/action#, occi.core.class=action, occi.core.term=offline, occi.core.title=Offline Storage Action}], [{occi.core.scheme=http://schemas.ogf.org/occi/infrastructure/storage/action#, occi.core.class=action, occi.core.term=backup, occi.core.title=Backup Storage Action}], [{occi.core.scheme=http://schemas.ogf.org/occi/infrastructure/storage/action#, occi.core.class=action, occi.core.term=snapshot, occi.core.title=Snapshot Storage Action}], [{occi.core.scheme=http://schemas.ogf.org/occi/infrastructure/storage/action#, occi.core.class=action, occi.core.term=resize, occi.core.title=Resize Storage Action}], [{occi.core.scheme=http://schemas.ogf.org/occi/infrastructure/storage/action#, occi.core.class=action, occi.core.term=degrade, occi.core.title=Degrade Storage Action}], [{occi.core.scheme=http://sla-at-soi.eu/occi/infrastructure/service/action#, occi.core.class=action, occi.core.term=stop, occi.core.title=A Stop Service Action}], [{occi.core.scheme=http://sla-at-soi.eu/occi/infrastructure/service/action#, occi.core.class=action, occi.core.term=start, occi.core.title=A Start Service Action}], [{occi.core.scheme=http://sla-at-soi.eu/occi/infrastructure/service/action#, occi.core.class=action, occi.core.term=restart, occi.core.title=A Restart Service Action}], [{occi.core.scheme=http://sla-at-soi.eu/occi/infrastructure/service/action#, occi.core.class=action, occi.core.term=suspend, occi.core.title=A Suspend Service Action}], [{occi.core.scheme=http://schemas.ogf.org/occi/core#, occi.core.class=kind, occi.core.term=entity, occi.core.attributes=occi.core.title occi.core.id, occi.core.title=Entity type}], [{occi.core.scheme=http://schemas.ogf.org/occi/core#, occi.core.class=kind, occi.core.term=resource, occi.core.attributes=occi.core.summary, occi.core.title=Resource type, occi.core.rel=http://schemas.ogf.org/occi/core#entity}], [{occi.core.actions=http://schemas.ogf.org/occi/infrastructure/compute/action#suspend http://schemas.ogf.org/occi/infrastructure/compute/action#stop http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#restart, occi.core.location=/compute, occi.core.scheme=http://schemas.ogf.org/occi/infrastructure#, occi.core.class=kind, occi.core.term=compute, occi.core.attributes=occi.compute.hostname occi.compute.architecture occi.compute.memory occi.compute.speed occi.compute.cores occi.compute.state, occi.core.title=Compute type, occi.core.rel=http://schemas.ogf.org/occi/core#resource}], [{occi.core.actions=http://schemas.ogf.org/occi/infrastructure/network/action#down http://schemas.ogf.org/occi/infrastructure/network/action#up, occi.core.location=/network, occi.core.scheme=http://schemas.ogf.org/occi/infrastructure#, occi.core.class=kind, occi.core.term=network, occi.core.attributes=occi.network.label occi.network.vlan occi.network.state, occi.core.title=Network type, occi.core.rel=http://schemas.ogf.org/occi/core#resource}], [{occi.core.actions=http://schemas.ogf.org/occi/infrastructure/storage/action#offline http://schemas.ogf.org/occi/infrastructure/storage/action#backup http://schemas.ogf.org/occi/infrastructure/storage/action#snapshot http://schemas.ogf.org/occi/infrastructure/storage/action#degrade http://schemas.ogf.org/occi/infrastructure/storage/action#resize http://schemas.ogf.org/occi/infrastructure/storage/action#online, occi.core.location=/storage, occi.core.scheme=http://schemas.ogf.org/occi/infrastructure#, occi.core.class=kind, occi.core.term=storage, occi.core.attributes=occi.storage.size occi.storage.state, occi.core.title=Storage type, occi.core.rel=http://schemas.ogf.org/occi/core#resource}], [{occi.core.actions=http://sla-at-soi.eu/occi/infrastructure/service/action#start http://sla-at-soi.eu/occi/infrastructure/service/action#stop http://sla-at-soi.eu/occi/infrastructure/service/action#suspend http://sla-at-soi.eu/occi/infrastructure/service/action#restart, occi.core.location=/service, occi.core.scheme=http://sla-at-soi.eu/occi/infrastructure#, occi.core.class=kind, occi.core.term=service, occi.core.attributes=eu.slasoi.infrastructure.service.monitoringconfig eu.slasoi.infrastructure.service.state eu.slasoi.infrastructure.service.name, occi.core.title=Service type, occi.core.rel=http://schemas.ogf.org/occi/core#resource}], [{occi.core.location=/link, occi.core.scheme=http://schemas.ogf.org/occi/core#, occi.core.class=kind, occi.core.term=link, occi.core.attributes=occi.core.target occi.core.source, occi.core.title=Link type, occi.core.rel=http://schemas.ogf.org/occi/core#entity}], [{occi.core.location=/link, occi.core.scheme=http://schemas.ogf.org/occi/infrastructure#, occi.core.class=kind, occi.core.term=networkinterface, occi.core.attributes=occi.networkinterface.state occi.networkinterface.interface occi.networkinterface.mac, occi.core.title=A network interface link, occi.core.rel=http://schemas.ogf.org/occi/core#link}], [{occi.core.location=/link, occi.core.scheme=http://schemas.ogf.org/occi/infrastructure#, occi.core.class=kind, occi.core.term=storagelink, occi.core.attributes=occi.storagelink.mountpoint occi.storagelink.state occi.storagelink.deviceid, occi.core.title=A storage link, occi.core.rel=http://schemas.ogf.org/occi/core#link}], [{occi.core.location=/compute, occi.core.scheme=http://sla-at-soi.eu/occi/infrastructure#, occi.core.class=mixin, occi.core.term=slasoicompute, occi.core.attributes=eu.sla-at-soi.image-identifier eu.sla-at-soi.physical-host, occi.core.title=A SLA@SOI specific compute}], [{occi.core.location=/network, occi.core.scheme=http://schemas.ogf.org/occi/infrastructure/network#, occi.core.class=mixin, occi.core.term=ipnetwork, occi.core.attributes=occi.network.address occi.network.gateway occi.network.allocation, occi.core.title=An IP Networking Mixin}], [{occi.core.location=/link, occi.core.scheme=http://schemas.ogf.org/occi/infrastructure/networkinterface#, occi.core.class=mixin, occi.core.term=ipnetworkinterface, occi.core.attributes=occi.networkinterface.address occi.networkinterface.gateway occi.networkinterface.allocation, occi.core.title=An IP Network Interface Mixin}], [{occi.core.location=/os_tpls, occi.core.scheme=http://schemas.ogf.org/occi/infrastructure#, occi.core.class=mixin, occi.core.term=os_tpl, occi.core.title=An OS Template Mixin}], [{occi.core.location=/resource_tpls, occi.core.scheme=http://schemas.ogf.org/occi/infrastructure#, occi.core.class=mixin, occi.core.term=resource_tpl, occi.core.title=A Resource Template Mixin}]], occi.links=[], occi.locations=[]} | |
*/ | |
package occi.lexpar.demo; | |
import java.util.HashMap; | |
import occi.lexpar.OcciParser; | |
public class OcciQueryListing { | |
public static String listing = | |
"Category: start; scheme='http://schemas.ogf.org/occi/infrastructure/compute/action#'; class='action'; title='Start Compute Action'\n"+ | |
"Category: stop; scheme='http://schemas.ogf.org/occi/infrastructure/compute/action#'; class='action'; title='Stop Compute Action'; attributes='acpioff graceful poweroff'\n"+ | |
"Category: restart; scheme='http://schemas.ogf.org/occi/infrastructure/compute/action#'; class='action'; title='Restart Compute Action'; attributes='warm graceful cold'\n"+ | |
"Category: suspend; scheme='http://schemas.ogf.org/occi/infrastructure/compute/action#'; class='action'; title='Suspend Compute Action'; attributes='hibernate suspend'\n"+ | |
"Category: up; scheme='http://schemas.ogf.org/occi/infrastructure/network/action#'; class='action'; title='Up Network Action'\n"+ | |
"Category: down; scheme='http://schemas.ogf.org/occi/infrastructure/network/action#'; class='action'; title='Down Network Action'\n"+ | |
"Category: online; scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#'; class='action'; title='Online Storage Action'\n"+ | |
"Category: offline; scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#'; class='action'; title='Offline Storage Action'\n"+ | |
"Category: backup; scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#'; class='action'; title='Backup Storage Action'\n"+ | |
"Category: snapshot; scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#'; class='action'; title='Snapshot Storage Action'\n"+ | |
"Category: resize; scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#'; class='action'; title='Resize Storage Action'\n"+ | |
"Category: degrade; scheme='http://schemas.ogf.org/occi/infrastructure/storage/action#'; class='action'; title='Degrade Storage Action'\n"+ | |
"Category: stop; scheme='http://sla-at-soi.eu/occi/infrastructure/service/action#'; class='action'; title='A Stop Service Action'\n"+ | |
"Category: start; scheme='http://sla-at-soi.eu/occi/infrastructure/service/action#'; class='action'; title='A Start Service Action'\n"+ | |
"Category: restart; scheme='http://sla-at-soi.eu/occi/infrastructure/service/action#'; class='action'; title='A Restart Service Action'\n"+ | |
"Category: suspend; scheme='http://sla-at-soi.eu/occi/infrastructure/service/action#'; class='action'; title='A Suspend Service Action'\n"+ | |
"Category: entity; scheme='http://schemas.ogf.org/occi/core#'; class='kind'; title='Entity type'; attributes='occi.core.title occi.core.id'\n"+ | |
"Category: resource; scheme='http://schemas.ogf.org/occi/core#'; class='kind'; title='Resource type'; rel='http://schemas.ogf.org/occi/core#entity'; attributes='occi.core.summary'\n"+ | |
"Category: compute; scheme='http://schemas.ogf.org/occi/infrastructure#'; class='kind'; title='Compute type'; rel='http://schemas.ogf.org/occi/core#resource'; location=/compute; attributes='occi.compute.hostname occi.compute.architecture occi.compute.memory occi.compute.speed occi.compute.cores occi.compute.state'; actions='http://schemas.ogf.org/occi/infrastructure/compute/action#suspend http://schemas.ogf.org/occi/infrastructure/compute/action#stop http://schemas.ogf.org/occi/infrastructure/compute/action#start http://schemas.ogf.org/occi/infrastructure/compute/action#restart'\n"+ | |
"Category: network; scheme='http://schemas.ogf.org/occi/infrastructure#'; class='kind'; title='Network type'; rel='http://schemas.ogf.org/occi/core#resource'; location=/network; attributes='occi.network.label occi.network.vlan occi.network.state'; actions='http://schemas.ogf.org/occi/infrastructure/network/action#down http://schemas.ogf.org/occi/infrastructure/network/action#up'\n"+ | |
"Category: storage; scheme='http://schemas.ogf.org/occi/infrastructure#'; class='kind'; title='Storage type'; rel='http://schemas.ogf.org/occi/core#resource'; location=/storage; attributes='occi.storage.size occi.storage.state'; actions='http://schemas.ogf.org/occi/infrastructure/storage/action#offline http://schemas.ogf.org/occi/infrastructure/storage/action#backup http://schemas.ogf.org/occi/infrastructure/storage/action#snapshot http://schemas.ogf.org/occi/infrastructure/storage/action#degrade http://schemas.ogf.org/occi/infrastructure/storage/action#resize http://schemas.ogf.org/occi/infrastructure/storage/action#online'\n"+ | |
"Category: service; scheme='http://sla-at-soi.eu/occi/infrastructure#'; class='kind'; title='Service type'; rel='http://schemas.ogf.org/occi/core#resource'; location=/service; attributes='eu.slasoi.infrastructure.service.monitoringconfig eu.slasoi.infrastructure.service.state eu.slasoi.infrastructure.service.name'; actions='http://sla-at-soi.eu/occi/infrastructure/service/action#start http://sla-at-soi.eu/occi/infrastructure/service/action#stop http://sla-at-soi.eu/occi/infrastructure/service/action#suspend http://sla-at-soi.eu/occi/infrastructure/service/action#restart'\n"+ | |
"Category: link; scheme='http://schemas.ogf.org/occi/core#'; class='kind'; title='Link type'; rel='http://schemas.ogf.org/occi/core#entity'; location=/link; attributes='occi.core.target occi.core.source'\n"+ | |
"Category: networkinterface; scheme='http://schemas.ogf.org/occi/infrastructure#'; class='kind'; title='A network interface link'; rel='http://schemas.ogf.org/occi/core#link'; location=/link; attributes='occi.networkinterface.state occi.networkinterface.interface occi.networkinterface.mac'\n"+ | |
"Category: storagelink; scheme='http://schemas.ogf.org/occi/infrastructure#'; class='kind'; title='A storage link'; rel='http://schemas.ogf.org/occi/core#link'; location=/link; attributes='occi.storagelink.mountpoint occi.storagelink.state occi.storagelink.deviceid'\n"+ | |
"Category: slasoicompute; scheme='http://sla-at-soi.eu/occi/infrastructure#'; class='mixin'; title='A SLA@SOI specific compute'; location=/compute; attributes='eu.sla-at-soi.image-identifier eu.sla-at-soi.physical-host'\n"+ | |
"Category: ipnetwork; scheme='http://schemas.ogf.org/occi/infrastructure/network#'; class='mixin'; title='An IP Networking Mixin'; location=/network; attributes='occi.network.address occi.network.gateway occi.network.allocation'\n"+ | |
"Category: ipnetworkinterface; scheme='http://schemas.ogf.org/occi/infrastructure/networkinterface#'; class='mixin'; title='An IP Network Interface Mixin'; location=/link; attributes='occi.networkinterface.address occi.networkinterface.gateway occi.networkinterface.allocation'\n"+ | |
"Category: os_tpl; scheme='http://schemas.ogf.org/occi/infrastructure#'; class='mixin'; title='An OS Template Mixin'; location=/os_tpls\n"+ | |
"Category: resource_tpl; scheme='http://schemas.ogf.org/occi/infrastructure#'; class='mixin'; title='A Resource Template Mixin'; location=/resource_tpls\n"; | |
public static void main(String[] args) { | |
//parse links | |
HashMap res; | |
try { | |
res = OcciParser.getParser(listing).headers(); | |
System.out.println("No errors on parsing link header."); | |
System.out.println("Result: " + res.toString() + "\n"); | |
} catch (Exception e2) { | |
e2.printStackTrace(); | |
System.exit(0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment