use of com.github.zhenwei.core.asn1.x509.Attribute in project rascal by usethesource.
the class DOM method nodeToAttribute.
private Attribute nodeToAttribute(IConstructor n) {
IConstructor ns = (IConstructor) n.get(0);
IString name = (IString) n.get(1);
IString data = (IString) n.get(2);
return new Attribute(name.getValue(), data.getValue(), namespaceToNamespace(ns));
}
use of com.github.zhenwei.core.asn1.x509.Attribute in project rascal by usethesource.
the class DOM method convertElement.
private IConstructor convertElement(Element e, boolean trim) {
IListWriter kids = vf.listWriter();
for (Object o : e.getAttributes()) {
Attribute attr = (Attribute) o;
IString key = vf.string(attr.getName());
IString val = vf.string(attr.getValue());
kids.insert(vf.constructor(Factory.Node_attribute, convertNamespace(attr.getNamespace()), key, val));
}
int len = e.getContentSize();
for (int i = 0; i < len; i++) {
try {
kids.append(convertContent(e.getContent(i), trim));
} catch (Skip c) {
// Ugh, terrible, but I'm in hurry
continue;
}
}
IString name = vf.string(e.getName());
return vf.constructor(Factory.Node_element, convertNamespace(e.getNamespace()), name, kids.done());
}
use of com.github.zhenwei.core.asn1.x509.Attribute in project s1tbx by senbox-org.
the class BinaryDBReader method DecodeElement.
private static void DecodeElement(final BinaryFileReader reader, final Map metaMap, final Element child, final String suffix) {
String name = "";
try {
final Attribute nameAttrib = child.getAttribute("name");
final Attribute typeAttrib = child.getAttribute("type");
final Attribute numAttrib = child.getAttribute("num");
if (nameAttrib != null && typeAttrib != null && numAttrib != null) {
name = nameAttrib.getValue();
if (suffix != null)
name += suffix;
final int type = Integer.parseInt(typeAttrib.getValue());
final int num = Integer.parseInt(numAttrib.getValue());
switch(type) {
case Skip:
{
// blank
reader.skipBytes(num);
break;
}
case An:
{
metaMap.put(name, reader.readAn(num));
break;
}
case In:
{
metaMap.put(name, (int) reader.readIn(num));
break;
}
case B1:
{
metaMap.put(name, reader.readB1());
break;
}
case B2:
{
metaMap.put(name, reader.readB2());
break;
}
case B4:
{
metaMap.put(name, reader.readB4());
break;
}
case B8:
{
metaMap.put(name, reader.readB8());
break;
}
case Fn:
{
metaMap.put(name, reader.readFn(num));
break;
}
case En:
{
metaMap.put(name, reader.readEn(num));
break;
}
case Debug:
{
System.out.print(" = ");
for (int i = 0; i < num; ++i) {
final String tmp = reader.readAn(1);
if (!tmp.isEmpty() && !tmp.equals(" "))
System.out.print(tmp);
}
System.out.println();
break;
}
default:
{
throw new IllegalBinaryFormatException("Unknown type " + type, reader.getCurrentPos());
}
}
}
} catch (Exception e) {
if (e.getCause() != null)
SystemUtils.LOG.severe(' ' + e.toString() + ':' + e.getCause().toString() + " for " + name);
else
SystemUtils.LOG.severe(' ' + e.toString() + ':' + " for " + name);
}
}
use of com.github.zhenwei.core.asn1.x509.Attribute in project s1tbx by senbox-org.
the class BinaryDBReader method DecodeElementDebug.
private void DecodeElementDebug(final BinaryFileReader reader, final Map metaMap, final Element child, final String suffix) {
String name = "";
try {
final Attribute nameAttrib = child.getAttribute("name");
final Attribute typeAttrib = child.getAttribute("type");
final Attribute numAttrib = child.getAttribute("num");
if (nameAttrib != null && typeAttrib != null && numAttrib != null) {
name = nameAttrib.getValue();
if (suffix != null)
name += suffix;
final int type = Integer.parseInt(typeAttrib.getValue());
final int num = Integer.parseInt(numAttrib.getValue());
System.out.print(" " + reader.getCurrentPos() + ' ' + (reader.getCurrentPos() - startPos + 1) + ' ' + name + ' ' + type + ' ' + num);
switch(type) {
case Skip:
{
// blank
reader.skipBytes(num);
break;
}
case An:
{
final String tmp = reader.readAn(num);
System.out.print(" = " + tmp);
metaMap.put(name, tmp);
break;
}
case In:
{
final int tmp = (int) reader.readIn(num);
System.out.print(" = " + tmp);
metaMap.put(name, tmp);
break;
}
case B1:
{
final int tmp = reader.readB1();
System.out.print(" = " + tmp);
metaMap.put(name, tmp);
break;
}
case B2:
{
final int tmp = reader.readB2();
System.out.print(" = " + tmp);
metaMap.put(name, tmp);
break;
}
case B4:
{
final int tmp = reader.readB4();
System.out.print(" = " + tmp);
metaMap.put(name, tmp);
break;
}
case B8:
{
final long tmp = reader.readB8();
System.out.print(" = " + tmp);
metaMap.put(name, tmp);
break;
}
case Fn:
{
double tmp = reader.readFn(num);
System.out.print(" = " + tmp);
metaMap.put(name, tmp);
break;
}
case En:
{
double tmp = reader.readEn(num);
System.out.print(" = " + tmp);
metaMap.put(name, tmp);
break;
}
case Debug:
{
System.out.print(" = ");
for (int i = 0; i < num; ++i) {
final String tmp = reader.readAn(1);
if (!tmp.isEmpty() && !tmp.equals(" "))
System.out.print(tmp);
}
System.out.println();
break;
}
default:
{
throw new IllegalBinaryFormatException("Unknown type " + type, reader.getCurrentPos());
}
}
System.out.println();
}
} catch (Exception e) {
if (e.getCause() != null)
SystemUtils.LOG.severe(' ' + e.toString() + ':' + e.getCause().toString() + " for " + name);
else
SystemUtils.LOG.severe(' ' + e.toString() + ':' + " for " + name);
// throw new IllegalBinaryFormatException(e.toString(), reader.getCurrentPos());
}
}
use of com.github.zhenwei.core.asn1.x509.Attribute in project s1tbx by senbox-org.
the class NetCDFUtils method addAttributes.
public static MetadataElement addAttributes(final MetadataElement parentElem, final String elemName, final List<Attribute> attribList) {
final MetadataElement globalElem = new MetadataElement(elemName);
parentElem.addElement(globalElem);
for (Attribute at : attribList) {
createMetadataAttributes(globalElem, at, at.getName());
}
return globalElem;
}
Aggregations