From: Xuan B. <med...@us...> - 2007-05-03 16:19:10
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/utils In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv11965/src/org/tm4j/topicmap/utils Modified Files: IDGeneratorFactory.java IDGeneratorImpl.java XTMWriter.java Log Message: Create nicer (non-auto-generated) IDs when writing XTM output, so that the XTM file is more readable. Index: IDGeneratorImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/utils/IDGeneratorImpl.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** IDGeneratorImpl.java 15 Dec 2004 08:43:09 -0000 1.9 --- IDGeneratorImpl.java 3 May 2007 16:19:07 -0000 1.10 *************** *** 1,3 **** ! /* Copyright (c) 2000-2004 The TM4J Project. All rights reserved. --- 1,3 ---- ! /* :indentSize=4:tabSize=4: Copyright (c) 2000-2004 The TM4J Project. All rights reserved. *************** *** 57,59 **** --- 57,63 ---- return m_instance.getID(); } + + protected String getBaseID() { + return baseID; + } } Index: XTMWriter.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/utils/XTMWriter.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** XTMWriter.java 3 May 2007 14:45:18 -0000 1.44 --- XTMWriter.java 3 May 2007 16:19:07 -0000 1.45 *************** *** 87,90 **** --- 87,95 ---- private LocatorFactory m_locFactory = new LocatorFactoryImpl(); private boolean m_exportSubjectIndicatorRefs = false; + + /** + Wether we want to try to write IDs which are not autogenerated. + */ + protected final static boolean enableNiceIDs = true; /** *************** *** 858,862 **** String ret = null; Iterator srcLocs = tmo.getSourceLocators().iterator(); ! while ((ret == null) && srcLocs.hasNext()) { Locator tmoResLoc = (Locator)srcLocs.next(); Locator tmResLoc = srcLoc; --- 863,868 ---- String ret = null; Iterator srcLocs = tmo.getSourceLocators().iterator(); ! ! while (srcLocs.hasNext()) { Locator tmoResLoc = (Locator)srcLocs.next(); Locator tmResLoc = srcLoc; *************** *** 873,877 **** if (getDocumentPart(uTmoResLoc.getAddress()).equals(tmAddress)) { ! return uTmoResLoc.getFragment(); } --- 879,887 ---- if (getDocumentPart(uTmoResLoc.getAddress()).equals(tmAddress)) { ! ret = uTmoResLoc.getFragment(); ! ! if (!enableNiceIDs||!looksLikeBeingAutoGenerated(ret)) { ! return ret; ! } } *************** *** 886,890 **** if (getDocumentPart(l.getAddress()).equals(tmAddress)) { ! return l.getFragment(); } } --- 896,904 ---- if (getDocumentPart(l.getAddress()).equals(tmAddress)) { ! ret = l.getFragment(); ! ! if (!enableNiceIDs||!looksLikeBeingAutoGenerated(ret)) { ! return ret; ! } } } *************** *** 894,897 **** --- 908,915 ---- return ret; } + + protected boolean looksLikeBeingAutoGenerated(String resourceID) { + return resourceID.startsWith(IDGeneratorFactory.ourIDGenerator().getBaseID()); + } /** *************** *** 949,952 **** --- 967,973 ---- /* * $Log$ + * Revision 1.45 2007/05/03 16:19:07 mediumnet + * Create nicer (non-auto-generated) IDs when writing XTM output, so that the XTM file is more readable. + * * Revision 1.44 2007/05/03 14:45:18 mediumnet * An assertion. Index: IDGeneratorFactory.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/utils/IDGeneratorFactory.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** IDGeneratorFactory.java 10 Sep 2004 12:45:17 -0000 1.8 --- IDGeneratorFactory.java 3 May 2007 16:19:07 -0000 1.9 *************** *** 54,60 **** --- 54,70 ---- return s_instance; } + + /** + only for optimization + */ + protected static IDGeneratorImpl ourIDGenerator() { + return (IDGeneratorImpl) s_instance; + } } /* * $Log$ + * Revision 1.9 2007/05/03 16:19:07 mediumnet + * Create nicer (non-auto-generated) IDs when writing XTM output, so that the XTM file is more readable. + * * Revision 1.8 2004/09/10 12:45:17 kal_ahmed * Moved IDGeneratorFactory to manage a singleton IDGenerator instance. |