org.bimserver.serializers.objectinfo.ObjectInfoSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of demoplugins Show documentation
Show all versions of demoplugins Show documentation
BIMserver plugins for demo purposes
package org.bimserver.serializers.objectinfo;
/******************************************************************************
* Copyright (C) 2009-2015 BIMserver.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*****************************************************************************/
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.List;
import org.bimserver.plugins.serializers.EmfSerializer;
import org.bimserver.plugins.serializers.ProgressReporter;
import org.bimserver.plugins.serializers.SerializerException;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
public class ObjectInfoSerializer extends EmfSerializer {
@Override
public void reset() {
setMode(Mode.BODY);
}
@Override
public boolean write(OutputStream outputStream, ProgressReporter progressReporter) throws SerializerException {
if (getMode() == Mode.BODY) {
PrintWriter out = new PrintWriter(outputStream);
for (EObject eObject : model.getObjects().values()) {
if (eObject.eClass().getEAnnotation("hidden") == null) {
writeTable(out, eObject);
}
}
out.flush();
setMode(Mode.FINISHED);
return true;
} else if (getMode() == Mode.FINISHED) {
return false;
}
return false;
}
@SuppressWarnings("unchecked")
private void writeTable(PrintWriter out, EObject eObject) {
out.println("" + eObject.eClass().getName() + "
");
out.println("");
for (EStructuralFeature eStructuralFeature : eObject.eClass().getEAllStructuralFeatures()) {
if (eStructuralFeature.getEAnnotation("hidden") == null) {
out.println("");
out.println("" + eStructuralFeature.getName() + " ");
Object eGet = eObject.eGet(eStructuralFeature);
if (eStructuralFeature instanceof EAttribute) {
if (eStructuralFeature.getUpperBound() == 1) {
out.println("" + eGet + " ");
} else {
List ");
}
out.println("
");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy