/* * [Item.java] * * Summary: Base class for script items we sort, namely SRItems and PathItems. * * Copyright: (c) 2011-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2011-11-13 initial version */ package com.mindprod.sortsrs; /** * Base class for script items we sort, namely SRItems and PathItems. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2011-11-13 initial version * @since 2011-11-13 */ abstract class Item { /** * which section of the script does this item belong in. * 1 = s/r * 2 = paths * 3. end */ int section; /** * used to ensure that empty strings are stored consistently as null rather than as "". * Does not trim lead or trail blanks. Does not intern. * * @param field field to store * * @return null if field empty or null, untouched otherwise. */ static String canonise( String field ) { if ( field == null || field.length() == 0 ) { return null; } else { return field; } } /** * compose a 1 to 4-line search/replace script item, with lead \r\n but no trailing \r\n * * @param stripComments true if should strip out comments * * @return chars as they appear is reconstructed script. */ abstract String combine( final boolean stripComments ); }