*/
public ModuleParserRSS1() {
}
public Module parse(Element element) {
CreativeCommonsImpl module = new CreativeCommonsImpl();
{
// Parsing Channel level.
Element root =element;
while(root.getParentElement() != null )
root = root.getParentElement();
List licenseList = root.getChildren( "License", NS );
ArrayList licenses = new ArrayList();
Iterator it = licenseList.iterator();
while( it.hasNext() ){
Element licenseTag = (Element) it.next();
String licenseURI = licenseTag.getAttributeValue("about", RDF);
if( licenseURI == null )
continue;
License license = License.findByValue( licenseURI );
{
ArrayList permitsValues = new ArrayList();
ArrayList requiresValues = new ArrayList();
List permitsTags = licenseTag.getChildren("permits", NS );
Iterator sit = permitsTags.iterator();
while(sit.hasNext() ){
Element permitTag = (Element) sit.next();
permitsValues.add( License.Behaviour.findByValue( permitTag.getAttributeValue( "resource", RDF) ));
}
List requiresTags = licenseTag.getChildren( "requires", NS);
sit = requiresTags.iterator();
while(sit.hasNext()){
Element requireTag = (Element) sit.next();
requiresValues.add( License.Behaviour.findByValue(requireTag.getAttributeValue("resource", RDF)));
}
license = new License( licenseURI,
(License.Behaviour[]) requiresValues.toArray( new License.Behaviour[requiresValues.size()]),
(License.Behaviour[]) permitsValues.toArray( new License.Behaviour[permitsValues.size()]) );
}
licenses.add( license );
}
module.setAllLicenses( (License[]) licenses.toArray( new License[0] ) );
}
ArrayList licenses = new ArrayList();
List licenseTags = element.getChildren( "license", NS );
Iterator lit = licenseTags.iterator();
while( lit.hasNext() ){
Element licenseTag = (Element) lit.next();
licenses.add( License.findByValue( licenseTag.getAttributeValue( "resource", RDF)));
}
if( licenses.size() > 0 ){
module.setLicenses( (License[]) licenses.toArray( new License[licenses.size()]));
}
if( module.getLicenses() != null || module.getAllLicenses() != null ){
return module;
} else {
return null;
}
}