On Wed, 21 Mar 2007, Matt Benson <[EMAIL PROTECTED]> wrote: > I think what is needed is a well-known syntax specification for > specifying a string representation of [resource-type][String to pass > to constructor] e.g. "file?/foo/bar.baz", > "url?http://www.apache.org", "string?blah blah blah".
This is so I can say <unzip src="url?http://www.apache.org/dist/ant/.../ant-bin-current.zip"/> instead of <unzip> <url url="http://www.apache.org/dist/ant/.../ant-bin-current.zip"/> </unzip> right? Sounds right. > One may recall this as something I've been after for awhile--I > consider it the "next step" for resource handling in Ant. For code > compartmentalization we could probably add the code to generate a > Resource from a String to ResourceUtils, but IH would know how to > use e.g. RU.getResource(Project, String) to set Resource attributes I guess we'd need something dynamic, i.e. there has to be a way to register a ressource prefix with RU so that I can have string representations for my own ressource types. > (for BC, FileResource would be the default). For BC we'd have to keep the File-argument setters anyway. IH could be changed to use setSrc(Ressource) in favor of setSrc(File) and use the later if no ressource mapping was found. No real need to have a default in RU. OTOH it might be convenient for users when they can simply omit the "file?" prefix for files. > This is to all intents and purposes the only way, IMHO, to seriously > take advantage in Ant tasks of our early decision to design > getOutputStream() into the Resource contract. You'll notice my use > of the "?" character above to indicate the preceding text was the > name of a currently available type. I used "?" because for xmlns as > well as fs reasons I'm pretty sure this character should NOT be a > colon. I agree that a colon would be a bad choice, at least if we allow file ressources to be specified without a prefix. I don't really see any conflict with xmlns. > However I'm not sure what the RIGHT "trigger character" is and IMO > this is the only outstanding question stopping us from adding this > feature to Ant. bikeshedding? 8-) "?" isn't pretty but works for me. "@" would probably work nicely (file@/usr/local/bin/xemacs) but may get unwieldy if you use constant ressource specifications inside of macrodefs (you'd have to double the "@"). No obvious choice IMHO, I'd take whatever you pick. > Aside from allowing IH to transform a String into a given Resource, > you'll see that tasks using mappers can choose to pass the mapped > names to this same factory code and work with resources, or they can > behave as normal and they will break if a user tries to map to an > arbitrary resource type Sounds good. > (assuming its string representation can't be misinterpreted as a > file, a situation I hope we'll be able to prevent esp. by choosing > the right "trigger character"). There won't be any such character. AFAIK the only forbidden character in Unix filenames is a / and this obviously is a very bad choice for the "trigger". "?" and "*" are unlikely in filenames, but both are used as wildcards in patterns - now that you mention using the string representation in mappers: <globmapper from="file?*.xml" to="url?http://home/*.html"/> Here the "?" might look ambiguos. OK, what is left? "#", "="? Or "url(http://www.apache.org/)"? Stefan --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]