You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stephen Colebourne <sc...@btopenworld.com> on 2006/01/01 18:13:33 UTC
[io] File content iterator
See http://issues.apache.org/bugzilla/show_bug.cgi?id=38083
The design for a line by line iterator over a file could potentially get
much more interesting.
The basic requirement is an iterator over Strings representing the file
lines, that does not load the whole file in the background. This implies
that the user is responsible for closing the iterator (although it could
be done automatically once the hasNext() returns false).
I was thinking of an class like this:
public class OpenFileLineIterator implements Iterator {
boolean hasNext();
String nextLine();
void close();
}
Is this a reasonable design?
Stephen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: semantic web identifiers?
Posted by Phil Steitz <ph...@gmail.com>.
+1 - this would make a good addition to [id] IMHO
Phil
On 1/6/06, Michael Heuer <he...@acm.org> wrote:
> Hello,
>
> Might there be interest in adding support for semantic web style
> identifiers? Currently one might use one of the PrefixedXxx
> serial generators to create String identifiers, and create e.g. URIs from
> those Strings in a second step, but I think it would be desireable to
> generate e.g. URIs directly:
>
> URIGenerator
> java.net.URI nextURI();
> URLGenerator
> java.net.URL nextURL();
> QNameGenerator
> javax.xml.namespace.QName nextQName();
>
> See:
>
> RDF URI-based Vocabulary and Node Identification
> > http://www.w3.org/TR/rdf-concepts/#section-URI-Vocabulary
>
> Namespaces in XML
> > http://www.w3.org/TR/REC-xml-names/
>
> XML Schema Part 2: Datatypes Second Edition
> > http://www.w3.org/TR/xmlschema-2/#QName
>
> michael
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[id] semantic web identifiers?
Posted by Michael Heuer <he...@acm.org>.
Hello,
Might there be interest in adding support for semantic web style
identifiers? Currently one might use one of the PrefixedXxx
serial generators to create String identifiers, and create e.g. URIs from
those Strings in a second step, but I think it would be desireable to
generate e.g. URIs directly:
URIGenerator
java.net.URI nextURI();
URLGenerator
java.net.URL nextURL();
QNameGenerator
javax.xml.namespace.QName nextQName();
See:
RDF URI-based Vocabulary and Node Identification
> http://www.w3.org/TR/rdf-concepts/#section-URI-Vocabulary
Namespaces in XML
> http://www.w3.org/TR/REC-xml-names/
XML Schema Part 2: Datatypes Second Edition
> http://www.w3.org/TR/xmlschema-2/#QName
michael
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [io] File content iterator
Posted by Stephen Colebourne <sc...@btopenworld.com>.
James Ring wrote:
>>I was thinking of an class like this:
>>
>>public class OpenFileLineIterator implements Iterator {
>> boolean hasNext();
>> String nextLine();
>> void close();
>>}
>
> Looks fine to me.. Did you intend to use a BufferedReader for the
> implementation of nextLine()?
>
> Also, maybe hasNext() will be a bit tricky to determine, because you don't
> know if you're at the end of a file until you try reading from it. Maybe this
> isn't a problem...
I would expect hasNext to actually read the next line and store it in
the iterator for nextLine() to return. That way its fairly easy to
implement.
Stephen
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [io] File content iterator
Posted by James Ring <sj...@jdns.org>.
Hi Stephen,
On Monday 02 January 2006 04:13, Stephen Colebourne wrote:
> See http://issues.apache.org/bugzilla/show_bug.cgi?id=38083
>
> The design for a line by line iterator over a file could potentially get
> much more interesting.
>
> The basic requirement is an iterator over Strings representing the file
> lines, that does not load the whole file in the background. This implies
> that the user is responsible for closing the iterator (although it could
> be done automatically once the hasNext() returns false).
>
> I was thinking of an class like this:
>
> public class OpenFileLineIterator implements Iterator {
> boolean hasNext();
> String nextLine();
> void close();
> }
>
> Is this a reasonable design?
Looks fine to me.. Did you intend to use a BufferedReader for the
implementation of nextLine()?
Also, maybe hasNext() will be a bit tricky to determine, because you don't
know if you're at the end of a file until you try reading from it. Maybe this
isn't a problem...
> Stephen
Regards,
James
--
James Ring