| | |
| | | * Dgn7fileReaderTest |
| | | * User: Ulysses |
| | | * Date: 2007/10/24 |
| | | * Time: ¤W¤È 01:43:41 |
| | | * Time: �W�� 01:43:41 |
| | | * To change this template use File | Settings | File Templates. |
| | | */ |
| | | public class Dgn7fileReaderTest |
| | | { |
| | | public class Dgn7fileReaderTest { |
| | | private final static Logger logger = Logger.getLogger(Dgn7fileReaderTest.class); |
| | | |
| | | // private final static String testFilePath = "test-data\\testHV.dgn"; |
| | |
| | | private FileInputStream _fs; |
| | | |
| | | @BeforeTest |
| | | public void setUp() throws IOException |
| | | { |
| | | public void setUp() throws IOException { |
| | | File dataFile = TestData.file(this, testFilePath); |
| | | if (!dataFile.exists()) |
| | | { |
| | | if (!dataFile.exists()) { |
| | | return; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Test |
| | | public void testRead() throws Dgn7fileException, IOException |
| | | { |
| | | public void testRead() throws Dgn7fileException, IOException { |
| | | if (_fs == null) return; |
| | | FileChannel fc = _fs.getChannel(); |
| | | 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(); |
| | | } |
| | |
| | | count++; |
| | | } |
| | | |
| | | logger.info("ElementRecord Count=" + count); |
| | | logger.info("FileRecord Count=" + count); |
| | | } |
| | | } |