forked from geodmms/xdgnjobs

Dennis Kao
2014-01-15 94ae08701bbd7585a0b7e5a92d1975965a503c03
xdgnjobs/ximple-dgnio/src/test/java/com/ximple/io/dgn7/Dgn7TextElementReaderTest.java
@@ -17,10 +17,8 @@
 * Dgn7TextElementReaderTest
 * User: Ulysses
 * Date: 2008/1/10
 * Time: ¤W¤È 12:19:14
 */
public class Dgn7TextElementReaderTest
{
public class Dgn7TextElementReaderTest {
    private final static Logger logger = Logger.getLogger(Dgn7fileReaderTest.class);
    private final static String testFilePathCreated = "demo.dgn";
@@ -30,16 +28,13 @@
    private FileInputStream _fs;
    @BeforeTest
    public void setUp() throws FileNotFoundException
    {
    public void setUp() throws FileNotFoundException {
    }
    @Test
    public void testRead() throws Dgn7fileException, IOException
    {
    public void testRead() throws Dgn7fileException, IOException {
        File dataFile = TestData.file(this, testFilePathCreated);
        if (dataFile.exists())
        {
        if (dataFile.exists()) {
            System.out.println("Output--" + testFilePathCreated);
            _fs = new FileInputStream(dataFile);
            FileChannel fc = _fs.getChannel();
@@ -49,8 +44,7 @@
        }
        dataFile = TestData.file(this, testFilePathExist);
        if (dataFile.exists())
        {
        if (dataFile.exists()) {
            System.out.println("Output--" + testFilePathExist);
            _fs = new FileInputStream(dataFile);
            FileChannel fc = _fs.getChannel();
@@ -60,8 +54,7 @@
        }
        dataFile = TestData.file(this, testFilePathPostComplete);
        if (dataFile.exists())
        {
        if (dataFile.exists()) {
            System.out.println("Output--" + testFilePathPostComplete);
            _fs = new FileInputStream(dataFile);
            FileChannel fc = _fs.getChannel();
@@ -71,97 +64,76 @@
        }
    }
    public void dumpElements(FileChannel fc) throws Dgn7fileException, IOException
    {
    public void dumpElements(FileChannel fc) throws Dgn7fileException, IOException {
        Dgn7fileReader reader = new Dgn7fileReader(fc, new Lock());
        int count = 0;
        Element lastComplex = null;
        while (reader.hasNext())
        {
            Dgn7fileReader.Record record = reader.nextElement();
            if (record.element() != null)
            {
        while (reader.hasNext()) {
            Element.FileRecord record = reader.nextElement();
            if (record.element() != null) {
                Element element = (Element) record.element();
                ElementType type = element.getElementType();
                if ((!type.isComplexElement()) && (!element.isComponentElement()))
                {
                    if (lastComplex != null)
                    {
                if ((!type.isComplexElement()) && (!element.isComponentElement())) {
                    if (lastComplex != null) {
                        // @todo add process in here
                        lastComplex = null;
                    }
                    // @todo add process in here
                } else if (element.isComponentElement())
                {
                    if (lastComplex != null)
                    {
                } else if (element.isComponentElement()) {
                    if (lastComplex != null) {
                        ((ComplexElement) lastComplex).add(element);
                    }
                } else if (type.isComplexElement())
                {
                    if (lastComplex == null)
                    {
                } else if (type.isComplexElement()) {
                    if (lastComplex == null) {
                        lastComplex = element;
                    } else
                    {
                    } else {
                        // @todo add process in here
                        lastComplex = element;
                    }
                }
                if (element.getElementType().isComplexElement())
                {
                    if (element instanceof ComplexChainElement)
                    {
                if (element.getElementType().isComplexElement()) {
                    if (element instanceof ComplexChainElement) {
                        ComplexChainElement complexChain = (ComplexChainElement) element;
                        int size = complexChain.size();
                        for (Object aComplexChain : complexChain)
                        {
                        for (Object aComplexChain : complexChain) {
                            Element subElement = (Element) aComplexChain;
                            subElement.getType();
                        }
                    }
                    if (element instanceof ComplexShapeElement)
                    {
                    if (element instanceof ComplexShapeElement) {
                        ComplexShapeElement complexShape = (ComplexShapeElement) element;
                    }
                    if (element instanceof TextNodeElement)
                    {
                    if (element instanceof TextNodeElement) {
                        TextNodeElement textNode = (TextNodeElement) element;
                        int size = textNode.size();
                        for (int i = 0; i < size; i++)
                        {
                        for (int i = 0; i < size; i++) {
                            Element subElement = (Element) textNode.get(i);
                            subElement.getElementType();
                        }
                    }
                } else
                {
                } else {
                    boolean hasLinkage = false;
                    if (element instanceof TextElement)
                    {
                    if (element instanceof TextElement) {
                        TextElement textElm = (TextElement) element;
                        List<UserAttributeData> usrData = textElm.getUserAttributeData();
                        Iterator<UserAttributeData> it = usrData.iterator();
                        while (it.hasNext())
                        {
                        while (it.hasNext()) {
                            UserAttributeData attr = it.next();
                            if (attr instanceof FrammeAttributeData)
                            {
                            if (attr instanceof FrammeAttributeData) {
                                hasLinkage = true;
                                System.out.println("------------------------------------------");
                                System.out.println("FSC=" + ((FrammeAttributeData) attr).getFsc() + ":" +
                                        ((FrammeAttributeData) attr).getUfid());
                                    ((FrammeAttributeData) attr).getUfid());
                            }
                        }
                        if (hasLinkage)
                        {
                        if (hasLinkage) {
                            System.out.println("Text.Font=" + textElm.getFontIndex());
                            System.out.println("Text.Just=" + textElm.getJustification());
                            System.out.println("usrData.len=" + usrData.size());
@@ -175,6 +147,6 @@
            count++;
        }
        logger.info("ElementRecord Count=" + count);
        logger.info("FileRecord Count=" + count);
    }
}