ruper2/src/java/core/org/krysalis/ruper/files DefaultResourceFilenameAnalyzer.java,1.4,1.5

[email protected]
Newsgroups gmane.comp.krysalis.metamorphosis.cvs
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/files
In directory sc8-pr-cvs1:/tmp/cvs-serv10667/src/java/core/org/krysalis/ruper/files

Modified Files:
	DefaultResourceFilenameAnalyzer.java 
Log Message:
1) listSpecifiers ought not work
2) unit tests run again [need to add those to a project]
3) FilenameAnalyzer a bit smarter (copes w/ -alpha better, ala Ben's soln)
4) FileUpdater does something -- kinda/sorta, try it :-)
5) Ant task same...

Index: DefaultResourceFilenameAnalyzer.java
===================================================================
RCS file: /cvsroot/metamorphosis/ruper2/src/java/core/org/krysalis/ruper/files/DefaultResourceFilenameAnalyzer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DefaultResourceFilenameAnalyzer.java	11 Sep 2003 16:29:59 -0000	1.4
--- DefaultResourceFilenameAnalyzer.java	12 Sep 2003 20:23:43 -0000	1.5
***************
*** 23,26 ****
--- 23,27 ----
  import org.krysalis.version.VersionException;
  import org.krysalis.version.impl.KrysalisVersion;
+ import org.krysalis.version.impl.data.ReleaseLevel;
  
  /**
***************
*** 97,101 ****
  				//
  				else {
! 					//:TODO: ???
  				}
  			}
--- 98,105 ----
  				//
  				else {
! 					Logger.getLog().error(
! 						Messages.getString(
! 							MessageConstants.WRONG_TYPE,
! 							entity));
  				}
  			}
***************
*** 166,170 ****
  	//
  	//		HACK HACK HACK -- to get us started. Will evolve into a
! 	//		whole configurable sub-system
  	//
  	void processString(
--- 170,174 ----
  	//
  	//		HACK HACK HACK -- to get us started. Will evolve into a
! 	//		whole configurable parsing sub-system
  	//
  	void processString(
***************
*** 197,210 ****
  		// Type is anything after the last - or _ so long as
  		//	it doesn't start with a digit (i.e. is the version)
  		//
! 		int typePosn = findSeparator(remainder);
  		if (-1 != typePosn) {
  			if (!Character.isDigit(remainder.charAt(typePosn + 1))) {
  				type = remainder.substring(typePosn + 1);
  
! 				//
! 				// What is left is name/version
! 				//
! 				remainder = remainder.substring(0, typePosn);
  			}
  		}
--- 201,224 ----
  		// Type is anything after the last - or _ so long as
  		//	it doesn't start with a digit (i.e. is the version)
+ 		// .. and so long as it isn't a release level
  		//
! 		int typePosn = findLastSeparator(remainder);
  		if (-1 != typePosn) {
  			if (!Character.isDigit(remainder.charAt(typePosn + 1))) {
  				type = remainder.substring(typePosn + 1);
  
! 				if (!ReleaseLevel
! 					.UNSET
! 					.equals(ReleaseLevel.getFromStringFailSafe(type))) {
! 					type = null; // ResourceType.JAVA_BINARY;
! 				}
! 				else {
! 
! 					//
! 					// What is left is name/version
! 					//
! 					remainder = remainder.substring(0, typePosn);
! 
! 				}
  			}
  		}
***************
*** 262,265 ****
--- 276,289 ----
  		}
  
+ 	}
+ 
+ 	int findLastSeparator(String input) {
+ 		return findLastSeparator(input, input.length());
+ 	}
+ 
+ 	int findLastSeparator(String input, int start) {
+ 		int dashPosn = input.lastIndexOf('-', start);
+ 		int underscorePosn = input.lastIndexOf('_', start);
+ 		return (dashPosn >= underscorePosn) ? dashPosn : underscorePosn;
  	}
  




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.