repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
mirage-sql/mirage
src/main/java/com/miragesql/miragesql/parser/SqlTokenizerImpl.java
SqlTokenizerImpl.parseComment
protected void parseComment() { int commentEndPos = sql.indexOf("*/", position); int commentEndPos2 = sql.indexOf("*#", position); if (0 < commentEndPos2 && commentEndPos2 < commentEndPos) { commentEndPos = commentEndPos2; } if (commentEndPos < 0) { ...
java
protected void parseComment() { int commentEndPos = sql.indexOf("*/", position); int commentEndPos2 = sql.indexOf("*#", position); if (0 < commentEndPos2 && commentEndPos2 < commentEndPos) { commentEndPos = commentEndPos2; } if (commentEndPos < 0) { ...
[ "protected", "void", "parseComment", "(", ")", "{", "int", "commentEndPos", "=", "sql", ".", "indexOf", "(", "\"*/\"", ",", "position", ")", ";", "int", "commentEndPos2", "=", "sql", ".", "indexOf", "(", "\"*#\"", ",", "position", ")", ";", "if", "(", ...
Parse the comment.
[ "Parse", "the", "comment", "." ]
29a44b7ad267b5a48bc250cd0ef7d74813d46889
https://github.com/mirage-sql/mirage/blob/29a44b7ad267b5a48bc250cd0ef7d74813d46889/src/main/java/com/miragesql/miragesql/parser/SqlTokenizerImpl.java#L184-L198
train
mirage-sql/mirage
src/main/java/com/miragesql/miragesql/bean/BeanDescFactory.java
BeanDescFactory.getBeanDesc
@SuppressWarnings("unchecked") public BeanDesc getBeanDesc(Object obj){ if(obj instanceof Map){ return new MapBeanDescImpl((Map<String, Object>) obj); } else { return getBeanDesc(obj.getClass()); } }
java
@SuppressWarnings("unchecked") public BeanDesc getBeanDesc(Object obj){ if(obj instanceof Map){ return new MapBeanDescImpl((Map<String, Object>) obj); } else { return getBeanDesc(obj.getClass()); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "BeanDesc", "getBeanDesc", "(", "Object", "obj", ")", "{", "if", "(", "obj", "instanceof", "Map", ")", "{", "return", "new", "MapBeanDescImpl", "(", "(", "Map", "<", "String", ",", "Object", ">"...
Constructs a bean descriptor out of an Object instance. @param obj the object to create the descriptor from (the object can also be a Map) @return a descriptor
[ "Constructs", "a", "bean", "descriptor", "out", "of", "an", "Object", "instance", "." ]
29a44b7ad267b5a48bc250cd0ef7d74813d46889
https://github.com/mirage-sql/mirage/blob/29a44b7ad267b5a48bc250cd0ef7d74813d46889/src/main/java/com/miragesql/miragesql/bean/BeanDescFactory.java#L35-L42
train
mirage-sql/mirage
src/main/java/com/miragesql/miragesql/bean/BeanDescFactory.java
BeanDescFactory.getBeanDesc
public BeanDesc getBeanDesc(Class<?> clazz){ if(clazz == Map.class || clazz == HashMap.class || clazz == LinkedHashMap.class){ return new MapBeanDescImpl(); } if(cacheEnabled && cacheMap.containsKey(clazz)){ return cacheMap.get(clazz); } BeanDes...
java
public BeanDesc getBeanDesc(Class<?> clazz){ if(clazz == Map.class || clazz == HashMap.class || clazz == LinkedHashMap.class){ return new MapBeanDescImpl(); } if(cacheEnabled && cacheMap.containsKey(clazz)){ return cacheMap.get(clazz); } BeanDes...
[ "public", "BeanDesc", "getBeanDesc", "(", "Class", "<", "?", ">", "clazz", ")", "{", "if", "(", "clazz", "==", "Map", ".", "class", "||", "clazz", "==", "HashMap", ".", "class", "||", "clazz", "==", "LinkedHashMap", ".", "class", ")", "{", "return", ...
Constructs a bean descriptor out of a class. @param clazz the class to create the descriptor from. For <code>Map.class</code>, <code>HashMap.class</code> and <code>LinkedHashMap.class</code> no properties can be extracted, so this operations needs to be done later. @return a descriptor
[ "Constructs", "a", "bean", "descriptor", "out", "of", "a", "class", "." ]
29a44b7ad267b5a48bc250cd0ef7d74813d46889
https://github.com/mirage-sql/mirage/blob/29a44b7ad267b5a48bc250cd0ef7d74813d46889/src/main/java/com/miragesql/miragesql/bean/BeanDescFactory.java#L51-L67
train
mirage-sql/mirage
src/main/java/com/miragesql/miragesql/parser/SqlParserImpl.java
SqlParserImpl.parseSql
protected void parseSql() { String sql = tokenizer.getToken(); if (isElseMode()) { sql = StringUtil.replace(sql, "--", ""); } Node node = peek(); if ((node instanceof IfNode || node instanceof ElseNode) && node.getChildSize() == 0) { ...
java
protected void parseSql() { String sql = tokenizer.getToken(); if (isElseMode()) { sql = StringUtil.replace(sql, "--", ""); } Node node = peek(); if ((node instanceof IfNode || node instanceof ElseNode) && node.getChildSize() == 0) { ...
[ "protected", "void", "parseSql", "(", ")", "{", "String", "sql", "=", "tokenizer", ".", "getToken", "(", ")", ";", "if", "(", "isElseMode", "(", ")", ")", "{", "sql", "=", "StringUtil", ".", "replace", "(", "sql", ",", "\"--\"", ",", "\"\"", ")", "...
Parse the SQL.
[ "Parse", "the", "SQL", "." ]
29a44b7ad267b5a48bc250cd0ef7d74813d46889
https://github.com/mirage-sql/mirage/blob/29a44b7ad267b5a48bc250cd0ef7d74813d46889/src/main/java/com/miragesql/miragesql/parser/SqlParserImpl.java#L79-L107
train
mirage-sql/mirage
src/main/java/com/miragesql/miragesql/parser/SqlParserImpl.java
SqlParserImpl.parseComment
protected void parseComment() { String comment = tokenizer.getToken(); if (isTargetComment(comment)) { if (isIfComment(comment)) { parseIf(); } else if (isBeginComment(comment)) { parseBegin(); } else if (isEndComment(comment)) {...
java
protected void parseComment() { String comment = tokenizer.getToken(); if (isTargetComment(comment)) { if (isIfComment(comment)) { parseIf(); } else if (isBeginComment(comment)) { parseBegin(); } else if (isEndComment(comment)) {...
[ "protected", "void", "parseComment", "(", ")", "{", "String", "comment", "=", "tokenizer", ".", "getToken", "(", ")", ";", "if", "(", "isTargetComment", "(", "comment", ")", ")", "{", "if", "(", "isIfComment", "(", "comment", ")", ")", "{", "parseIf", ...
Parse an SQL comment.
[ "Parse", "an", "SQL", "comment", "." ]
29a44b7ad267b5a48bc250cd0ef7d74813d46889
https://github.com/mirage-sql/mirage/blob/29a44b7ad267b5a48bc250cd0ef7d74813d46889/src/main/java/com/miragesql/miragesql/parser/SqlParserImpl.java#L112-L127
train
mirage-sql/mirage
src/main/java/com/miragesql/miragesql/parser/SqlParserImpl.java
SqlParserImpl.parseIf
protected void parseIf() { String condition = tokenizer.getToken().substring(2).trim(); if (StringUtil.isEmpty(condition)) { throw new TwoWaySQLException("If condition not found."); } IfNode ifNode = new IfNode(condition); peek().addChild(ifNode); push(...
java
protected void parseIf() { String condition = tokenizer.getToken().substring(2).trim(); if (StringUtil.isEmpty(condition)) { throw new TwoWaySQLException("If condition not found."); } IfNode ifNode = new IfNode(condition); peek().addChild(ifNode); push(...
[ "protected", "void", "parseIf", "(", ")", "{", "String", "condition", "=", "tokenizer", ".", "getToken", "(", ")", ".", "substring", "(", "2", ")", ".", "trim", "(", ")", ";", "if", "(", "StringUtil", ".", "isEmpty", "(", "condition", ")", ")", "{", ...
Parse an IF node.
[ "Parse", "an", "IF", "node", "." ]
29a44b7ad267b5a48bc250cd0ef7d74813d46889
https://github.com/mirage-sql/mirage/blob/29a44b7ad267b5a48bc250cd0ef7d74813d46889/src/main/java/com/miragesql/miragesql/parser/SqlParserImpl.java#L132-L141
train
mirage-sql/mirage
src/main/java/com/miragesql/miragesql/parser/SqlParserImpl.java
SqlParserImpl.parseBegin
protected void parseBegin() { BeginNode beginNode = new BeginNode(); peek().addChild(beginNode); push(beginNode); parseEnd(); }
java
protected void parseBegin() { BeginNode beginNode = new BeginNode(); peek().addChild(beginNode); push(beginNode); parseEnd(); }
[ "protected", "void", "parseBegin", "(", ")", "{", "BeginNode", "beginNode", "=", "new", "BeginNode", "(", ")", ";", "peek", "(", ")", ".", "addChild", "(", "beginNode", ")", ";", "push", "(", "beginNode", ")", ";", "parseEnd", "(", ")", ";", "}" ]
Parse a BEGIN node.
[ "Parse", "a", "BEGIN", "node", "." ]
29a44b7ad267b5a48bc250cd0ef7d74813d46889
https://github.com/mirage-sql/mirage/blob/29a44b7ad267b5a48bc250cd0ef7d74813d46889/src/main/java/com/miragesql/miragesql/parser/SqlParserImpl.java#L146-L151
train
mirage-sql/mirage
src/main/java/com/miragesql/miragesql/parser/SqlParserImpl.java
SqlParserImpl.parseEnd
protected void parseEnd() { while (TokenType.EOF != tokenizer.next()) { if (tokenizer.getTokenType() == TokenType.COMMENT && isEndComment(tokenizer.getToken())) { pop(); return; } parseToken(); } t...
java
protected void parseEnd() { while (TokenType.EOF != tokenizer.next()) { if (tokenizer.getTokenType() == TokenType.COMMENT && isEndComment(tokenizer.getToken())) { pop(); return; } parseToken(); } t...
[ "protected", "void", "parseEnd", "(", ")", "{", "while", "(", "TokenType", ".", "EOF", "!=", "tokenizer", ".", "next", "(", ")", ")", "{", "if", "(", "tokenizer", ".", "getTokenType", "(", ")", "==", "TokenType", ".", "COMMENT", "&&", "isEndComment", "...
Parse an END node.
[ "Parse", "an", "END", "node", "." ]
29a44b7ad267b5a48bc250cd0ef7d74813d46889
https://github.com/mirage-sql/mirage/blob/29a44b7ad267b5a48bc250cd0ef7d74813d46889/src/main/java/com/miragesql/miragesql/parser/SqlParserImpl.java#L156-L168
train
mirage-sql/mirage
src/main/java/com/miragesql/miragesql/parser/SqlParserImpl.java
SqlParserImpl.parseElse
protected void parseElse() { Node parent = peek(); if (!(parent instanceof IfNode)) { return; } IfNode ifNode = (IfNode) pop(); ElseNode elseNode = new ElseNode(); ifNode.setElseNode(elseNode); push(elseNode); tokenizer.skipWhitespace(...
java
protected void parseElse() { Node parent = peek(); if (!(parent instanceof IfNode)) { return; } IfNode ifNode = (IfNode) pop(); ElseNode elseNode = new ElseNode(); ifNode.setElseNode(elseNode); push(elseNode); tokenizer.skipWhitespace(...
[ "protected", "void", "parseElse", "(", ")", "{", "Node", "parent", "=", "peek", "(", ")", ";", "if", "(", "!", "(", "parent", "instanceof", "IfNode", ")", ")", "{", "return", ";", "}", "IfNode", "ifNode", "=", "(", "IfNode", ")", "pop", "(", ")", ...
Parse an ELSE node.
[ "Parse", "an", "ELSE", "node", "." ]
29a44b7ad267b5a48bc250cd0ef7d74813d46889
https://github.com/mirage-sql/mirage/blob/29a44b7ad267b5a48bc250cd0ef7d74813d46889/src/main/java/com/miragesql/miragesql/parser/SqlParserImpl.java#L173-L183
train
mirage-sql/mirage
src/main/java/com/miragesql/miragesql/parser/SqlParserImpl.java
SqlParserImpl.parseBindVariable
protected void parseBindVariable() { String expr = tokenizer.getToken(); peek().addChild(new BindVariableNode(expr, beanDescFactory)); }
java
protected void parseBindVariable() { String expr = tokenizer.getToken(); peek().addChild(new BindVariableNode(expr, beanDescFactory)); }
[ "protected", "void", "parseBindVariable", "(", ")", "{", "String", "expr", "=", "tokenizer", ".", "getToken", "(", ")", ";", "peek", "(", ")", ".", "addChild", "(", "new", "BindVariableNode", "(", "expr", ",", "beanDescFactory", ")", ")", ";", "}" ]
Parse the bind variable.
[ "Parse", "the", "bind", "variable", "." ]
29a44b7ad267b5a48bc250cd0ef7d74813d46889
https://github.com/mirage-sql/mirage/blob/29a44b7ad267b5a48bc250cd0ef7d74813d46889/src/main/java/com/miragesql/miragesql/parser/SqlParserImpl.java#L205-L208
train
iipc/webarchive-commons
src/main/java/org/archive/io/WriterPool.java
WriterPool.makeNewWriterIfAppropriate
protected synchronized WriterPoolMember makeNewWriterIfAppropriate() { long now = System.currentTimeMillis(); lastWriterNeededTime = now; if(currentActive < maxActive) { currentActive++; lastWriterRolloverTime = now; return makeWriter(); } return ...
java
protected synchronized WriterPoolMember makeNewWriterIfAppropriate() { long now = System.currentTimeMillis(); lastWriterNeededTime = now; if(currentActive < maxActive) { currentActive++; lastWriterRolloverTime = now; return makeWriter(); } return ...
[ "protected", "synchronized", "WriterPoolMember", "makeNewWriterIfAppropriate", "(", ")", "{", "long", "now", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "lastWriterNeededTime", "=", "now", ";", "if", "(", "currentActive", "<", "maxActive", ")", "{", ...
Create a new writer instance, if still below maxActive count. Remember times to help make later decision when writer should be discarded. @return WriterPoolMember or null if already at max
[ "Create", "a", "new", "writer", "instance", "if", "still", "below", "maxActive", "count", ".", "Remember", "times", "to", "help", "make", "later", "decision", "when", "writer", "should", "be", "discarded", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/WriterPool.java#L148-L157
train
iipc/webarchive-commons
src/main/java/org/archive/io/WriterPool.java
WriterPool.invalidateFile
public synchronized void invalidateFile(WriterPoolMember f) throws IOException { try { destroyWriter(f); } catch (Exception e) { // Convert exception. throw new IOException(e.getMessage()); } // It'll have been closed. Rename with an '.invalid' su...
java
public synchronized void invalidateFile(WriterPoolMember f) throws IOException { try { destroyWriter(f); } catch (Exception e) { // Convert exception. throw new IOException(e.getMessage()); } // It'll have been closed. Rename with an '.invalid' su...
[ "public", "synchronized", "void", "invalidateFile", "(", "WriterPoolMember", "f", ")", "throws", "IOException", "{", "try", "{", "destroyWriter", "(", "f", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// Convert exception.", "throw", "new", "IOExc...
Close and discard a writer that experienced a potentially-corrupting error. @param f writer with problem @throws IOException
[ "Close", "and", "discard", "a", "writer", "that", "experienced", "a", "potentially", "-", "corrupting", "error", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/WriterPool.java#L209-L222
train
iipc/webarchive-commons
src/main/java/org/archive/io/HeaderedArchiveRecord.java
HeaderedArchiveRecord.skipHttpHeader
public void skipHttpHeader() throws IOException { if (this.contentHeaderStream == null) { return; } // Empty the contentHeaderStream for (int available = this.contentHeaderStream.available(); this.contentHeaderStream != null && (available = this.co...
java
public void skipHttpHeader() throws IOException { if (this.contentHeaderStream == null) { return; } // Empty the contentHeaderStream for (int available = this.contentHeaderStream.available(); this.contentHeaderStream != null && (available = this.co...
[ "public", "void", "skipHttpHeader", "(", ")", "throws", "IOException", "{", "if", "(", "this", ".", "contentHeaderStream", "==", "null", ")", "{", "return", ";", "}", "// Empty the contentHeaderStream", "for", "(", "int", "available", "=", "this", ".", "conten...
Skip over the the content headers if present. Subsequent reads will get the body. <p>Calling this method in the midst of reading the header will make for strange results. Otherwise, safe to call at any time though before reading any of the record content is only time that it makes sense. <p>After calling this metho...
[ "Skip", "over", "the", "the", "content", "headers", "if", "present", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/HeaderedArchiveRecord.java#L92-L107
train
iipc/webarchive-commons
src/main/java/org/archive/io/HeaderedArchiveRecord.java
HeaderedArchiveRecord.readContentHeaders
private InputStream readContentHeaders() throws IOException { // If judged a record that doesn't have an http header, return // immediately. if (!hasContentHeaders()) { return null; } byte [] statusBytes = LaxHttpParser.readRawLine(getIn()); int eolCharCount =...
java
private InputStream readContentHeaders() throws IOException { // If judged a record that doesn't have an http header, return // immediately. if (!hasContentHeaders()) { return null; } byte [] statusBytes = LaxHttpParser.readRawLine(getIn()); int eolCharCount =...
[ "private", "InputStream", "readContentHeaders", "(", ")", "throws", "IOException", "{", "// If judged a record that doesn't have an http header, return", "// immediately.", "if", "(", "!", "hasContentHeaders", "(", ")", ")", "{", "return", "null", ";", "}", "byte", "[",...
Read header if present. Technique borrowed from HttpClient HttpParse class. Using http parser code for now. Later move to more generic header parsing code if there proves a need. @return ByteArrayInputStream with the http header in it or null if no http header. @throws IOException
[ "Read", "header", "if", "present", ".", "Technique", "borrowed", "from", "HttpClient", "HttpParse", "class", ".", "Using", "http", "parser", "code", "for", "now", ".", "Later", "move", "to", "more", "generic", "header", "parsing", "code", "if", "there", "pro...
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/HeaderedArchiveRecord.java#L140-L212
train
iipc/webarchive-commons
src/main/java/org/archive/util/ProcessUtils.java
ProcessUtils.exec
public static ProcessUtils.ProcessResult exec(String [] args) throws IOException { Process p = Runtime.getRuntime().exec(args); ProcessUtils pu = new ProcessUtils(); // Gobble up any output. StreamGobbler err = pu.new StreamGobbler(p.getErrorStream(), "stderr"); err.setDaemon...
java
public static ProcessUtils.ProcessResult exec(String [] args) throws IOException { Process p = Runtime.getRuntime().exec(args); ProcessUtils pu = new ProcessUtils(); // Gobble up any output. StreamGobbler err = pu.new StreamGobbler(p.getErrorStream(), "stderr"); err.setDaemon...
[ "public", "static", "ProcessUtils", ".", "ProcessResult", "exec", "(", "String", "[", "]", "args", ")", "throws", "IOException", "{", "Process", "p", "=", "Runtime", ".", "getRuntime", "(", ")", ".", "exec", "(", "args", ")", ";", "ProcessUtils", "pu", "...
Runs process. @param args List of process args. @return A ProcessResult data structure. @throws IOException If interrupted, we throw an IOException. If non-zero exit code, we throw an IOException (This may need to change).
[ "Runs", "process", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/ProcessUtils.java#L124-L150
train
iipc/webarchive-commons
src/main/java/org/archive/io/RecordingOutputStream.java
RecordingOutputStream.open
public void open(OutputStream wrappedStream) throws IOException { if(isOpen()) { // error; should not be opening/wrapping in an unclosed // stream remains open throw new IOException("ROS already open for " +Thread.currentThread().getName()); } ...
java
public void open(OutputStream wrappedStream) throws IOException { if(isOpen()) { // error; should not be opening/wrapping in an unclosed // stream remains open throw new IOException("ROS already open for " +Thread.currentThread().getName()); } ...
[ "public", "void", "open", "(", "OutputStream", "wrappedStream", ")", "throws", "IOException", "{", "if", "(", "isOpen", "(", ")", ")", "{", "// error; should not be opening/wrapping in an unclosed ", "// stream remains open", "throw", "new", "IOException", "(", "\"ROS a...
Wrap the given stream, both recording and passing along any data written to this RecordingOutputStream. @param wrappedStream Stream to wrap. May be null for case where we want to write to a file backed stream only. @throws IOException If failed creation of backing file.
[ "Wrap", "the", "given", "stream", "both", "recording", "and", "passing", "along", "any", "data", "written", "to", "this", "RecordingOutputStream", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/RecordingOutputStream.java#L195-L205
train
iipc/webarchive-commons
src/main/java/org/archive/io/RecordingOutputStream.java
RecordingOutputStream.checkLimits
protected void checkLimits() throws RecorderIOException { // too much material before finding end of headers? if (messageBodyBeginMark<0) { // no mark yet if(position>MAX_HEADER_MATERIAL) { throw new RecorderTooMuchHeaderException(); } } ...
java
protected void checkLimits() throws RecorderIOException { // too much material before finding end of headers? if (messageBodyBeginMark<0) { // no mark yet if(position>MAX_HEADER_MATERIAL) { throw new RecorderTooMuchHeaderException(); } } ...
[ "protected", "void", "checkLimits", "(", ")", "throws", "RecorderIOException", "{", "// too much material before finding end of headers? ", "if", "(", "messageBodyBeginMark", "<", "0", ")", "{", "// no mark yet", "if", "(", "position", ">", "MAX_HEADER_MATERIAL", ")", "...
Check any enforced limits.
[ "Check", "any", "enforced", "limits", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/RecordingOutputStream.java#L313-L341
train
iipc/webarchive-commons
src/main/java/org/archive/io/RecordingOutputStream.java
RecordingOutputStream.record
private void record(int b) throws IOException { if (this.shouldDigest) { this.digest.update((byte)b); } if (this.position >= this.buffer.length) { this.ensureDiskStream().write(b); } else { this.buffer[(int) this.position] = (byte) b; } ...
java
private void record(int b) throws IOException { if (this.shouldDigest) { this.digest.update((byte)b); } if (this.position >= this.buffer.length) { this.ensureDiskStream().write(b); } else { this.buffer[(int) this.position] = (byte) b; } ...
[ "private", "void", "record", "(", "int", "b", ")", "throws", "IOException", "{", "if", "(", "this", ".", "shouldDigest", ")", "{", "this", ".", "digest", ".", "update", "(", "(", "byte", ")", "b", ")", ";", "}", "if", "(", "this", ".", "position", ...
Record the given byte for later recovery @param b Int to record. @exception IOException Failed write to backing file.
[ "Record", "the", "given", "byte", "for", "later", "recovery" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/RecordingOutputStream.java#L350-L360
train
iipc/webarchive-commons
src/main/java/org/archive/io/RecordingOutputStream.java
RecordingOutputStream.record
private void record(byte[] b, int off, int len) throws IOException { if(this.shouldDigest) { assert this.digest != null: "Digest is null."; this.digest.update(b, off, len); } tailRecord(b, off, len); }
java
private void record(byte[] b, int off, int len) throws IOException { if(this.shouldDigest) { assert this.digest != null: "Digest is null."; this.digest.update(b, off, len); } tailRecord(b, off, len); }
[ "private", "void", "record", "(", "byte", "[", "]", "b", ",", "int", "off", ",", "int", "len", ")", "throws", "IOException", "{", "if", "(", "this", ".", "shouldDigest", ")", "{", "assert", "this", ".", "digest", "!=", "null", ":", "\"Digest is null.\"...
Record the given byte-array range for recovery later @param b Buffer to record. @param off Offset into buffer at which to start recording. @param len Length of buffer to record. @exception IOException Failed write to backing file.
[ "Record", "the", "given", "byte", "-", "array", "range", "for", "recovery", "later" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/RecordingOutputStream.java#L371-L377
train
iipc/webarchive-commons
src/main/java/org/archive/io/RecordingOutputStream.java
RecordingOutputStream.tailRecord
private void tailRecord(byte[] b, int off, int len) throws IOException { if(this.position >= this.buffer.length){ this.ensureDiskStream().write(b, off, len); this.position += len; } else { assert this.buffer != null: "Buffer is null"; int toCopy = (int)Mat...
java
private void tailRecord(byte[] b, int off, int len) throws IOException { if(this.position >= this.buffer.length){ this.ensureDiskStream().write(b, off, len); this.position += len; } else { assert this.buffer != null: "Buffer is null"; int toCopy = (int)Mat...
[ "private", "void", "tailRecord", "(", "byte", "[", "]", "b", ",", "int", "off", ",", "int", "len", ")", "throws", "IOException", "{", "if", "(", "this", ".", "position", ">=", "this", ".", "buffer", ".", "length", ")", "{", "this", ".", "ensureDiskSt...
Record without digesting. @param b Buffer to record. @param off Offset into buffer at which to start recording. @param len Length of buffer to record. @exception IOException Failed write to backing file.
[ "Record", "without", "digesting", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/RecordingOutputStream.java#L388-L403
train
iipc/webarchive-commons
src/main/java/org/archive/io/RecordingOutputStream.java
RecordingOutputStream.setLimits
public void setLimits(long length, long milliseconds, long rateKBps) { maxLength = (length>0) ? length : Long.MAX_VALUE; timeoutMs = (milliseconds>0) ? milliseconds : Long.MAX_VALUE; maxRateBytesPerMs = (rateKBps>0) ? rateKBps*1024/1000 : Long.MAX_VALUE; }
java
public void setLimits(long length, long milliseconds, long rateKBps) { maxLength = (length>0) ? length : Long.MAX_VALUE; timeoutMs = (milliseconds>0) ? milliseconds : Long.MAX_VALUE; maxRateBytesPerMs = (rateKBps>0) ? rateKBps*1024/1000 : Long.MAX_VALUE; }
[ "public", "void", "setLimits", "(", "long", "length", ",", "long", "milliseconds", ",", "long", "rateKBps", ")", "{", "maxLength", "=", "(", "length", ">", "0", ")", "?", "length", ":", "Long", ".", "MAX_VALUE", ";", "timeoutMs", "=", "(", "milliseconds"...
Set limits on length, time, and rate to enforce. @param length @param milliseconds @param rateKBps
[ "Set", "limits", "on", "length", "time", "and", "rate", "to", "enforce", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/RecordingOutputStream.java#L605-L609
train
iipc/webarchive-commons
src/main/java/org/archive/io/RecordingOutputStream.java
RecordingOutputStream.resetLimits
public void resetLimits() { maxLength = Long.MAX_VALUE; timeoutMs = Long.MAX_VALUE; maxRateBytesPerMs = Long.MAX_VALUE; }
java
public void resetLimits() { maxLength = Long.MAX_VALUE; timeoutMs = Long.MAX_VALUE; maxRateBytesPerMs = Long.MAX_VALUE; }
[ "public", "void", "resetLimits", "(", ")", "{", "maxLength", "=", "Long", ".", "MAX_VALUE", ";", "timeoutMs", "=", "Long", ".", "MAX_VALUE", ";", "maxRateBytesPerMs", "=", "Long", ".", "MAX_VALUE", ";", "}" ]
Reset limits to effectively-unlimited defaults
[ "Reset", "limits", "to", "effectively", "-", "unlimited", "defaults" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/RecordingOutputStream.java#L614-L618
train
iipc/webarchive-commons
src/main/java/org/archive/util/zip/GZIPMembersInputStream.java
GZIPMembersInputStream.countingStream
protected static InputStream countingStream(InputStream in, int lookback) throws IOException { CountingInputStream cin = new CountingInputStream(in); cin.mark(lookback); return cin; }
java
protected static InputStream countingStream(InputStream in, int lookback) throws IOException { CountingInputStream cin = new CountingInputStream(in); cin.mark(lookback); return cin; }
[ "protected", "static", "InputStream", "countingStream", "(", "InputStream", "in", ",", "int", "lookback", ")", "throws", "IOException", "{", "CountingInputStream", "cin", "=", "new", "CountingInputStream", "(", "in", ")", ";", "cin", ".", "mark", "(", "lookback"...
A CountingInputStream is inserted to read compressed-offsets. @param in stream to wrap @param lookback tolerance of initial mark @return original stream wrapped in CountingInputStream @throws IOException
[ "A", "CountingInputStream", "is", "inserted", "to", "read", "compressed", "-", "offsets", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/zip/GZIPMembersInputStream.java#L91-L95
train
iipc/webarchive-commons
src/main/java/org/archive/io/GenericReplayCharSequence.java
GenericReplayCharSequence.charAt
public char charAt(int index) { if (index < 0 || index >= this.length()) { throw new IndexOutOfBoundsException("index=" + index + " - should be between 0 and length()=" + this.length()); } // is it in the buffer if (index < prefixBuffer.limit()) { ...
java
public char charAt(int index) { if (index < 0 || index >= this.length()) { throw new IndexOutOfBoundsException("index=" + index + " - should be between 0 and length()=" + this.length()); } // is it in the buffer if (index < prefixBuffer.limit()) { ...
[ "public", "char", "charAt", "(", "int", "index", ")", "{", "if", "(", "index", "<", "0", "||", "index", ">=", "this", ".", "length", "(", ")", ")", "{", "throw", "new", "IndexOutOfBoundsException", "(", "\"index=\"", "+", "index", "+", "\" - should be be...
Get character at passed absolute position. @param index Index into content @return Character at offset <code>index</code>.
[ "Get", "character", "at", "passed", "absolute", "position", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/GenericReplayCharSequence.java#L276-L309
train
iipc/webarchive-commons
src/main/java/org/archive/url/LaxURLCodec.java
LaxURLCodec.decodeUrlLoose
public static final byte[] decodeUrlLoose(byte[] bytes) { if (bytes == null) { return null; } ByteArrayOutputStream buffer = new ByteArrayOutputStream(); for (int i = 0; i < bytes.length; i++) { int b = bytes[i]; if (b == '+') { b...
java
public static final byte[] decodeUrlLoose(byte[] bytes) { if (bytes == null) { return null; } ByteArrayOutputStream buffer = new ByteArrayOutputStream(); for (int i = 0; i < bytes.length; i++) { int b = bytes[i]; if (b == '+') { b...
[ "public", "static", "final", "byte", "[", "]", "decodeUrlLoose", "(", "byte", "[", "]", "bytes", ")", "{", "if", "(", "bytes", "==", "null", ")", "{", "return", "null", ";", "}", "ByteArrayOutputStream", "buffer", "=", "new", "ByteArrayOutputStream", "(", ...
Decodes an array of URL safe 7-bit characters into an array of original bytes. Escaped characters are converted back to their original representation. Differs from URLCodec.decodeUrl() in that it throws no exceptions; bad or incomplete escape sequences are ignored and passed into result undecoded. This matches the beh...
[ "Decodes", "an", "array", "of", "URL", "safe", "7", "-", "bit", "characters", "into", "an", "array", "of", "original", "bytes", ".", "Escaped", "characters", "are", "converted", "back", "to", "their", "original", "representation", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/url/LaxURLCodec.java#L54-L82
train
iipc/webarchive-commons
src/main/java/org/archive/url/LaxURLCodec.java
LaxURLCodec.encode
public String encode(BitSet safe, String pString, String cs) throws UnsupportedEncodingException { if (pString == null) { return null; } return new String(encodeUrl(safe,pString.getBytes(cs)), Charsets.US_ASCII); }
java
public String encode(BitSet safe, String pString, String cs) throws UnsupportedEncodingException { if (pString == null) { return null; } return new String(encodeUrl(safe,pString.getBytes(cs)), Charsets.US_ASCII); }
[ "public", "String", "encode", "(", "BitSet", "safe", ",", "String", "pString", ",", "String", "cs", ")", "throws", "UnsupportedEncodingException", "{", "if", "(", "pString", "==", "null", ")", "{", "return", "null", ";", "}", "return", "new", "String", "("...
Encodes a string into its URL safe form using the specified string charset. Unsafe characters are escaped. This method is analogous to superclass encode() methods, additionally offering the ability to specify a different 'safe' character set (such as EXPANDED_URI_SAFE). @param safe BitSet of characters that don't nee...
[ "Encodes", "a", "string", "into", "its", "URL", "safe", "form", "using", "the", "specified", "string", "charset", ".", "Unsafe", "characters", "are", "escaped", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/url/LaxURLCodec.java#L153-L159
train
iipc/webarchive-commons
src/main/java/org/archive/util/SurtPrefixSet.java
SurtPrefixSet.importFrom
public void importFrom(Reader r) { BufferedReader reader = new BufferedReader(r); String s; Iterator<String> iter = new RegexLineIterator( new LineReadingIterator(reader), RegexLineIterator.COMMENT_LINE, RegexLineI...
java
public void importFrom(Reader r) { BufferedReader reader = new BufferedReader(r); String s; Iterator<String> iter = new RegexLineIterator( new LineReadingIterator(reader), RegexLineIterator.COMMENT_LINE, RegexLineI...
[ "public", "void", "importFrom", "(", "Reader", "r", ")", "{", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "r", ")", ";", "String", "s", ";", "Iterator", "<", "String", ">", "iter", "=", "new", "RegexLineIterator", "(", "new", "LineReadin...
Read a set of SURT prefixes from a reader source; keep sorted and with redundant entries removed. @param r reader over file of SURT_format strings @throws IOException
[ "Read", "a", "set", "of", "SURT", "prefixes", "from", "a", "reader", "source", ";", "keep", "sorted", "and", "with", "redundant", "entries", "removed", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/SurtPrefixSet.java#L61-L76
train
iipc/webarchive-commons
src/main/java/org/archive/util/SurtPrefixSet.java
SurtPrefixSet.importFromMixed
public void importFromMixed(Reader r, boolean deduceFromSeeds) { BufferedReader reader = new BufferedReader(r); String s; Iterator<String> iter = new RegexLineIterator( new LineReadingIterator(reader), RegexLineIterator.COMMENT_LINE, ...
java
public void importFromMixed(Reader r, boolean deduceFromSeeds) { BufferedReader reader = new BufferedReader(r); String s; Iterator<String> iter = new RegexLineIterator( new LineReadingIterator(reader), RegexLineIterator.COMMENT_LINE, ...
[ "public", "void", "importFromMixed", "(", "Reader", "r", ",", "boolean", "deduceFromSeeds", ")", "{", "BufferedReader", "reader", "=", "new", "BufferedReader", "(", "r", ")", ";", "String", "s", ";", "Iterator", "<", "String", ">", "iter", "=", "new", "Reg...
Import SURT prefixes from a reader with mixed URI and SURT prefix format. @param r the reader to import the prefixes from @param deduceFromSeeds true to also import SURT prefixes implied from normal URIs/hostname seeds
[ "Import", "SURT", "prefixes", "from", "a", "reader", "with", "mixed", "URI", "and", "SURT", "prefix", "format", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/SurtPrefixSet.java#L107-L131
train
iipc/webarchive-commons
src/main/java/org/archive/util/SURT.java
SURT.fromURI
public static String fromURI(String s, boolean preserveCase) { Matcher m = TextUtils.getMatcher(URI_SPLITTER,s); if(!m.matches()) { // not an authority-based URI scheme; return unchanged TextUtils.recycleMatcher(m); return s; } // preallocate enough sp...
java
public static String fromURI(String s, boolean preserveCase) { Matcher m = TextUtils.getMatcher(URI_SPLITTER,s); if(!m.matches()) { // not an authority-based URI scheme; return unchanged TextUtils.recycleMatcher(m); return s; } // preallocate enough sp...
[ "public", "static", "String", "fromURI", "(", "String", "s", ",", "boolean", "preserveCase", ")", "{", "Matcher", "m", "=", "TextUtils", ".", "getMatcher", "(", "URI_SPLITTER", ",", "s", ")", ";", "if", "(", "!", "m", ".", "matches", "(", ")", ")", "...
Utility method for creating the SURT form of the URI in the given String. If it appears a bit convoluted in its approach, note that it was optimized to minimize object-creation after allocation-sites profiling indicated this method was a top source of garbage in long-running crawls. Assumes that the String URI has al...
[ "Utility", "method", "for", "creating", "the", "SURT", "form", "of", "the", "URI", "in", "the", "given", "String", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/SURT.java#L121-L164
train
iipc/webarchive-commons
src/main/java/org/archive/net/rsync/Handler.java
Handler.main
public static void main(String[] args) throws IOException { if (args.length != 1) { System.out.println("Usage: java java " + "-Djava.protocol.handler.pkgs=org.archive.net " + "org.archive.net.rsync.Handler RSYNC_URL"); System.exit(1); } ...
java
public static void main(String[] args) throws IOException { if (args.length != 1) { System.out.println("Usage: java java " + "-Djava.protocol.handler.pkgs=org.archive.net " + "org.archive.net.rsync.Handler RSYNC_URL"); System.exit(1); } ...
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "IOException", "{", "if", "(", "args", ".", "length", "!=", "1", ")", "{", "System", ".", "out", ".", "println", "(", "\"Usage: java java \"", "+", "\"-Djava.protocol.handl...
Main dumps rsync file to STDOUT. @param args @throws IOException
[ "Main", "dumps", "rsync", "file", "to", "STDOUT", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/net/rsync/Handler.java#L47-L70
train
iipc/webarchive-commons
src/main/java/org/archive/io/ArraySeekInputStream.java
ArraySeekInputStream.position
public void position(long p) throws IOException { if ((p < 0) || (p > array.length)) { throw new IOException("Invalid position: " + p); } offset = (int)p; }
java
public void position(long p) throws IOException { if ((p < 0) || (p > array.length)) { throw new IOException("Invalid position: " + p); } offset = (int)p; }
[ "public", "void", "position", "(", "long", "p", ")", "throws", "IOException", "{", "if", "(", "(", "p", "<", "0", ")", "||", "(", "p", ">", "array", ".", "length", ")", ")", "{", "throw", "new", "IOException", "(", "\"Invalid position: \"", "+", "p",...
Repositions the stream. @param p the new position for the stream @throws IOException if the given position is out of bounds
[ "Repositions", "the", "stream", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/ArraySeekInputStream.java#L99-L104
train
iipc/webarchive-commons
src/main/java/org/archive/format/cdx/FieldSplitFormat.java
FieldSplitFormat.getFieldIndex
public int getFieldIndex(String name) { Integer val = this.nameToIndex.get(name); if (val == null) { return -1; } return val; }
java
public int getFieldIndex(String name) { Integer val = this.nameToIndex.get(name); if (val == null) { return -1; } return val; }
[ "public", "int", "getFieldIndex", "(", "String", "name", ")", "{", "Integer", "val", "=", "this", ".", "nameToIndex", ".", "get", "(", "name", ")", ";", "if", "(", "val", "==", "null", ")", "{", "return", "-", "1", ";", "}", "return", "val", ";", ...
Return field index for given name @param name @return
[ "Return", "field", "index", "for", "given", "name" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/format/cdx/FieldSplitFormat.java#L82-L88
train
iipc/webarchive-commons
src/main/java/org/archive/util/binsearch/ByteBufferInputStream.java
ByteBufferInputStream.map
public static ByteBufferInputStream map( final FileChannel fileChannel, final MapMode mapMode ) throws IOException { final long size = fileChannel.size(); final int chunks = (int)( ( size + ( CHUNK_SIZE - 1 ) ) / CHUNK_SIZE ); final ByteBuffer[] byteBuffer = new ByteBuffer[ chunks ]; for( int i = 0; i < chunks;...
java
public static ByteBufferInputStream map( final FileChannel fileChannel, final MapMode mapMode ) throws IOException { final long size = fileChannel.size(); final int chunks = (int)( ( size + ( CHUNK_SIZE - 1 ) ) / CHUNK_SIZE ); final ByteBuffer[] byteBuffer = new ByteBuffer[ chunks ]; for( int i = 0; i < chunks;...
[ "public", "static", "ByteBufferInputStream", "map", "(", "final", "FileChannel", "fileChannel", ",", "final", "MapMode", "mapMode", ")", "throws", "IOException", "{", "final", "long", "size", "=", "fileChannel", ".", "size", "(", ")", ";", "final", "int", "chu...
Creates a new byte-buffer input stream by mapping a given file channel. @param fileChannel the file channel that will be mapped. @param mapMode this must be {@link MapMode#READ_ONLY}. @return a new byte-buffer input stream over the contents of <code>fileChannel</code>.
[ "Creates", "a", "new", "byte", "-", "buffer", "input", "stream", "by", "mapping", "a", "given", "file", "channel", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/binsearch/ByteBufferInputStream.java#L123-L135
train
iipc/webarchive-commons
src/main/java/org/archive/util/DateUtils.java
DateUtils.formatMillisecondsToConventional
public static String formatMillisecondsToConventional(long duration, int unitCount) { if(unitCount <=0) { unitCount = 5; } if(duration==0) { return "0ms"; } StringBuffer sb = new StringBuffer(); if(duration<0) { sb.append("-");...
java
public static String formatMillisecondsToConventional(long duration, int unitCount) { if(unitCount <=0) { unitCount = 5; } if(duration==0) { return "0ms"; } StringBuffer sb = new StringBuffer(); if(duration<0) { sb.append("-");...
[ "public", "static", "String", "formatMillisecondsToConventional", "(", "long", "duration", ",", "int", "unitCount", ")", "{", "if", "(", "unitCount", "<=", "0", ")", "{", "unitCount", "=", "5", ";", "}", "if", "(", "duration", "==", "0", ")", "{", "retur...
Convert milliseconds value to a human-readable duration of mixed units, using units no larger than days. For example, "5d12h13m12s113ms" or "19h51m". @param duration @param unitCount how many significant units to show, at most for example, a value of 2 would show days+hours or hours+seconds but not hours+second+millis...
[ "Convert", "milliseconds", "value", "to", "a", "human", "-", "readable", "duration", "of", "mixed", "units", "using", "units", "no", "larger", "than", "days", ".", "For", "example", "5d12h13m12s113ms", "or", "19h51m", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/DateUtils.java#L610-L636
train
iipc/webarchive-commons
src/main/java/org/archive/util/DateUtils.java
DateUtils.getUnique14DigitDate
public synchronized static String getUnique14DigitDate(){ long effectiveNow = System.currentTimeMillis(); effectiveNow = Math.max(effectiveNow, LAST_UNIQUE_NOW14+1); String candidate = get14DigitDate(effectiveNow); while(candidate.equals(LAST_TIMESTAMP14)) { effectiveNo...
java
public synchronized static String getUnique14DigitDate(){ long effectiveNow = System.currentTimeMillis(); effectiveNow = Math.max(effectiveNow, LAST_UNIQUE_NOW14+1); String candidate = get14DigitDate(effectiveNow); while(candidate.equals(LAST_TIMESTAMP14)) { effectiveNo...
[ "public", "synchronized", "static", "String", "getUnique14DigitDate", "(", ")", "{", "long", "effectiveNow", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "effectiveNow", "=", "Math", ".", "max", "(", "effectiveNow", ",", "LAST_UNIQUE_NOW14", "+", "1",...
Utility function for creating UNIQUE-from-this-class arc-style date stamps in the format yyyMMddHHmmss. Rather than giving a duplicate datestamp on a subsequent call, will increment the seconds until a unique value is returned. Date stamps are in the UTC time zone @return the date stamp
[ "Utility", "function", "for", "creating", "UNIQUE", "-", "from", "-", "this", "-", "class", "arc", "-", "style", "date", "stamps", "in", "the", "format", "yyyMMddHHmmss", ".", "Rather", "than", "giving", "a", "duplicate", "datestamp", "on", "a", "subsequent"...
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/DateUtils.java#L650-L661
train
iipc/webarchive-commons
src/main/java/org/archive/util/iterator/LineReadingIterator.java
LineReadingIterator.lookahead
protected boolean lookahead() { try { next = this.reader.readLine(); if(next == null) { // TODO: make this close-on-exhaust optional? reader.close(); } return (next!=null); } catch (IOException e) { logger.warnin...
java
protected boolean lookahead() { try { next = this.reader.readLine(); if(next == null) { // TODO: make this close-on-exhaust optional? reader.close(); } return (next!=null); } catch (IOException e) { logger.warnin...
[ "protected", "boolean", "lookahead", "(", ")", "{", "try", "{", "next", "=", "this", ".", "reader", ".", "readLine", "(", ")", ";", "if", "(", "next", "==", "null", ")", "{", "// TODO: make this close-on-exhaust optional?", "reader", ".", "close", "(", ")"...
Loads next line into lookahead spot @return whether any item was loaded into next field
[ "Loads", "next", "line", "into", "lookahead", "spot" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/iterator/LineReadingIterator.java#L46-L58
train
iipc/webarchive-commons
src/main/java/org/archive/format/cdx/CDXFile.java
CDXFile.decodeGZToTemp
public static File decodeGZToTemp(String uriGZ) throws IOException { final int BUFFER_SIZE = 8192; Stream stream = null; try { stream = GeneralURIStreamFactory.createStream(uriGZ); InputStream input = new StreamWrappedInputStream(stream); input = new OpenJDK7GZIPInputStream(input); File uncompresse...
java
public static File decodeGZToTemp(String uriGZ) throws IOException { final int BUFFER_SIZE = 8192; Stream stream = null; try { stream = GeneralURIStreamFactory.createStream(uriGZ); InputStream input = new StreamWrappedInputStream(stream); input = new OpenJDK7GZIPInputStream(input); File uncompresse...
[ "public", "static", "File", "decodeGZToTemp", "(", "String", "uriGZ", ")", "throws", "IOException", "{", "final", "int", "BUFFER_SIZE", "=", "8192", ";", "Stream", "stream", "=", "null", ";", "try", "{", "stream", "=", "GeneralURIStreamFactory", ".", "createSt...
Decode gzipped cdx to a temporary file
[ "Decode", "gzipped", "cdx", "to", "a", "temporary", "file" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/format/cdx/CDXFile.java#L53-L83
train
iipc/webarchive-commons
src/main/java/org/archive/format/cdx/FieldSplitLine.java
FieldSplitLine.getField
public String getField(String name, String defaultVal) { int index = getFieldIndex(name); return (isInRange(index) ? this.fields.get(index) : defaultVal); }
java
public String getField(String name, String defaultVal) { int index = getFieldIndex(name); return (isInRange(index) ? this.fields.get(index) : defaultVal); }
[ "public", "String", "getField", "(", "String", "name", ",", "String", "defaultVal", ")", "{", "int", "index", "=", "getFieldIndex", "(", "name", ")", ";", "return", "(", "isInRange", "(", "index", ")", "?", "this", ".", "fields", ".", "get", "(", "inde...
Return field for given name, or defaultVal if not found @param name @return
[ "Return", "field", "for", "given", "name", "or", "defaultVal", "if", "not", "found" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/format/cdx/FieldSplitLine.java#L94-L97
train
iipc/webarchive-commons
src/main/java/org/archive/util/FileUtils.java
FileUtils.copyFile
public static boolean copyFile(final File src, final File dest) throws FileNotFoundException, IOException { return copyFile(src, dest, -1, true); }
java
public static boolean copyFile(final File src, final File dest) throws FileNotFoundException, IOException { return copyFile(src, dest, -1, true); }
[ "public", "static", "boolean", "copyFile", "(", "final", "File", "src", ",", "final", "File", "dest", ")", "throws", "FileNotFoundException", ",", "IOException", "{", "return", "copyFile", "(", "src", ",", "dest", ",", "-", "1", ",", "true", ")", ";", "}...
Copy the src file to the destination. Deletes any preexisting file at destination. @param src @param dest @return True if the extent was greater than actual bytes copied. @throws FileNotFoundException @throws IOException
[ "Copy", "the", "src", "file", "to", "the", "destination", ".", "Deletes", "any", "preexisting", "file", "at", "destination", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/FileUtils.java#L71-L74
train
iipc/webarchive-commons
src/main/java/org/archive/util/FileUtils.java
FileUtils.copyFile
public static boolean copyFile(final File src, final File dest, long extent, final boolean overwrite) throws FileNotFoundException, IOException { boolean result = false; if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Copying file " + src + " to " + dest + " extent " + ...
java
public static boolean copyFile(final File src, final File dest, long extent, final boolean overwrite) throws FileNotFoundException, IOException { boolean result = false; if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Copying file " + src + " to " + dest + " extent " + ...
[ "public", "static", "boolean", "copyFile", "(", "final", "File", "src", ",", "final", "File", "dest", ",", "long", "extent", ",", "final", "boolean", "overwrite", ")", "throws", "FileNotFoundException", ",", "IOException", "{", "boolean", "result", "=", "false...
Copy up to extent bytes of the source file to the destination @param src @param dest @param extent Maximum number of bytes to copy @param overwrite If target file already exits, and this parameter is true, overwrite target file (We do this by first deleting the target file before we begin the copy). @return True if th...
[ "Copy", "up", "to", "extent", "bytes", "of", "the", "source", "file", "to", "the", "destination" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/FileUtils.java#L106-L177
train
iipc/webarchive-commons
src/main/java/org/archive/util/FileUtils.java
FileUtils.getFilesWithPrefix
public static File [] getFilesWithPrefix(File dir, final String prefix) { FileFilter prefixFilter = new FileFilter() { public boolean accept(File pathname) { return pathname.getName().toLowerCase(). startsWith(prefix.toLowerCase()); ...
java
public static File [] getFilesWithPrefix(File dir, final String prefix) { FileFilter prefixFilter = new FileFilter() { public boolean accept(File pathname) { return pathname.getName().toLowerCase(). startsWith(prefix.toLowerCase()); ...
[ "public", "static", "File", "[", "]", "getFilesWithPrefix", "(", "File", "dir", ",", "final", "String", "prefix", ")", "{", "FileFilter", "prefixFilter", "=", "new", "FileFilter", "(", ")", "{", "public", "boolean", "accept", "(", "File", "pathname", ")", ...
Get a list of all files in directory that have passed prefix. @param dir Dir to look in. @param prefix Basename of files to look for. Compare is case insensitive. @return List of files in dir that start w/ passed basename.
[ "Get", "a", "list", "of", "all", "files", "in", "directory", "that", "have", "passed", "prefix", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/FileUtils.java#L218-L227
train
iipc/webarchive-commons
src/main/java/org/archive/util/FileUtils.java
FileUtils.assertReadable
public static File assertReadable(final File f) throws FileNotFoundException { if (!f.exists()) { throw new FileNotFoundException(f.getAbsolutePath() + " does not exist."); } if (!f.canRead()) { throw new FileNotFoundException(f.getAbsolutePath() + ...
java
public static File assertReadable(final File f) throws FileNotFoundException { if (!f.exists()) { throw new FileNotFoundException(f.getAbsolutePath() + " does not exist."); } if (!f.canRead()) { throw new FileNotFoundException(f.getAbsolutePath() + ...
[ "public", "static", "File", "assertReadable", "(", "final", "File", "f", ")", "throws", "FileNotFoundException", "{", "if", "(", "!", "f", ".", "exists", "(", ")", ")", "{", "throw", "new", "FileNotFoundException", "(", "f", ".", "getAbsolutePath", "(", ")...
Test file exists and is readable. @param f File to test. @exception FileNotFoundException If file does not exist or is not unreadable.
[ "Test", "file", "exists", "and", "is", "readable", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/FileUtils.java#L261-L273
train
iipc/webarchive-commons
src/main/java/org/archive/util/FileUtils.java
FileUtils.loadProperties
public static Properties loadProperties(File file) throws IOException { FileInputStream finp = new FileInputStream(file); try { Properties p = new Properties(); p.load(finp); return p; } finally { ArchiveUtils.closeQuietly(finp); } }
java
public static Properties loadProperties(File file) throws IOException { FileInputStream finp = new FileInputStream(file); try { Properties p = new Properties(); p.load(finp); return p; } finally { ArchiveUtils.closeQuietly(finp); } }
[ "public", "static", "Properties", "loadProperties", "(", "File", "file", ")", "throws", "IOException", "{", "FileInputStream", "finp", "=", "new", "FileInputStream", "(", "file", ")", ";", "try", "{", "Properties", "p", "=", "new", "Properties", "(", ")", ";...
Load Properties instance from a File @param file @return Properties @throws IOException
[ "Load", "Properties", "instance", "from", "a", "File" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/FileUtils.java#L335-L344
train
iipc/webarchive-commons
src/main/java/org/archive/util/FileUtils.java
FileUtils.storeProperties
public static void storeProperties(Properties p, File file) throws IOException { FileOutputStream fos = new FileOutputStream(file); try { p.store(fos,""); } finally { ArchiveUtils.closeQuietly(fos); } }
java
public static void storeProperties(Properties p, File file) throws IOException { FileOutputStream fos = new FileOutputStream(file); try { p.store(fos,""); } finally { ArchiveUtils.closeQuietly(fos); } }
[ "public", "static", "void", "storeProperties", "(", "Properties", "p", ",", "File", "file", ")", "throws", "IOException", "{", "FileOutputStream", "fos", "=", "new", "FileOutputStream", "(", "file", ")", ";", "try", "{", "p", ".", "store", "(", "fos", ",",...
Store Properties instance to a File @param p @param file destination File @throws IOException
[ "Store", "Properties", "instance", "to", "a", "File" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/FileUtils.java#L352-L359
train
iipc/webarchive-commons
src/main/java/org/archive/util/FileUtils.java
FileUtils.ensureWriteableDirectory
public static List<File> ensureWriteableDirectory(List<File> dirs) throws IOException { for (Iterator<File> i = dirs.iterator(); i.hasNext();) { FileUtils.ensureWriteableDirectory(i.next()); } return dirs; }
java
public static List<File> ensureWriteableDirectory(List<File> dirs) throws IOException { for (Iterator<File> i = dirs.iterator(); i.hasNext();) { FileUtils.ensureWriteableDirectory(i.next()); } return dirs; }
[ "public", "static", "List", "<", "File", ">", "ensureWriteableDirectory", "(", "List", "<", "File", ">", "dirs", ")", "throws", "IOException", "{", "for", "(", "Iterator", "<", "File", ">", "i", "=", "dirs", ".", "iterator", "(", ")", ";", "i", ".", ...
Ensure writeable directories. If doesn't exist, we attempt creation. @param dirs List of Files to test. @return The passed <code>dirs</code>. @exception IOException If passed directory does not exist and is not createable, or directory is not writeable or is not a directory.
[ "Ensure", "writeable", "directories", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/FileUtils.java#L652-L658
train
iipc/webarchive-commons
src/main/java/org/archive/util/FileUtils.java
FileUtils.ensureWriteableDirectory
public static File ensureWriteableDirectory(File dir) throws IOException { if (!dir.exists()) { boolean success = dir.mkdirs(); if (!success) { throw new IOException("Failed to create directory: " + dir); } } else { if (!dir.canWrite())...
java
public static File ensureWriteableDirectory(File dir) throws IOException { if (!dir.exists()) { boolean success = dir.mkdirs(); if (!success) { throw new IOException("Failed to create directory: " + dir); } } else { if (!dir.canWrite())...
[ "public", "static", "File", "ensureWriteableDirectory", "(", "File", "dir", ")", "throws", "IOException", "{", "if", "(", "!", "dir", ".", "exists", "(", ")", ")", "{", "boolean", "success", "=", "dir", ".", "mkdirs", "(", ")", ";", "if", "(", "!", "...
Ensure writeable directory. If doesn't exist, we attempt creation. @param dir Directory to test for exitence and is writeable. @return The passed <code>dir</code>. @exception IOException If passed directory does not exist and is not createable, or directory is not writeable or is not a directory.
[ "Ensure", "writeable", "directory", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/FileUtils.java#L672-L690
train
iipc/webarchive-commons
src/main/java/org/archive/util/Recorder.java
Recorder.inputWrap
public InputStream inputWrap(InputStream is) throws IOException { logger.fine(Thread.currentThread().getName() + " wrapping input"); // discard any state from previously-recorded input this.characterEncoding = null; this.inputIsChunked = false; this.contentEncoding ...
java
public InputStream inputWrap(InputStream is) throws IOException { logger.fine(Thread.currentThread().getName() + " wrapping input"); // discard any state from previously-recorded input this.characterEncoding = null; this.inputIsChunked = false; this.contentEncoding ...
[ "public", "InputStream", "inputWrap", "(", "InputStream", "is", ")", "throws", "IOException", "{", "logger", ".", "fine", "(", "Thread", ".", "currentThread", "(", ")", ".", "getName", "(", ")", "+", "\" wrapping input\"", ")", ";", "// discard any state from pr...
Wrap the provided stream with the internal RecordingInputStream open() throws an exception if RecordingInputStream is already open. @param is InputStream to wrap. @return The input stream wrapper which itself is an input stream. Pass this in place of the passed stream so input can be recorded. @throws IOException
[ "Wrap", "the", "provided", "stream", "with", "the", "internal", "RecordingInputStream" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/Recorder.java#L176-L187
train
iipc/webarchive-commons
src/main/java/org/archive/util/Recorder.java
Recorder.close
public void close() { logger.fine(Thread.currentThread().getName() + " closing"); try { this.ris.close(); } catch (IOException e) { // TODO: Can we not let the exception out of here and report it // higher up in the caller? DevUtils.logger.log(Leve...
java
public void close() { logger.fine(Thread.currentThread().getName() + " closing"); try { this.ris.close(); } catch (IOException e) { // TODO: Can we not let the exception out of here and report it // higher up in the caller? DevUtils.logger.log(Leve...
[ "public", "void", "close", "(", ")", "{", "logger", ".", "fine", "(", "Thread", ".", "currentThread", "(", ")", ".", "getName", "(", ")", "+", "\" closing\"", ")", ";", "try", "{", "this", ".", "ris", ".", "close", "(", ")", ";", "}", "catch", "(...
Close all streams.
[ "Close", "all", "streams", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/Recorder.java#L210-L226
train
iipc/webarchive-commons
src/main/java/org/archive/util/Recorder.java
Recorder.closeRecorders
public void closeRecorders() { try { this.ris.closeRecorder(); this.ros.closeRecorder(); } catch (IOException e) { DevUtils.warnHandle(e, "Convert to runtime exception?"); } }
java
public void closeRecorders() { try { this.ris.closeRecorder(); this.ros.closeRecorder(); } catch (IOException e) { DevUtils.warnHandle(e, "Convert to runtime exception?"); } }
[ "public", "void", "closeRecorders", "(", ")", "{", "try", "{", "this", ".", "ris", ".", "closeRecorder", "(", ")", ";", "this", ".", "ros", ".", "closeRecorder", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "DevUtils", ".", "warnHa...
Close both input and output recorders. Recorders are the output streams to which we are recording. {@link #close()} closes the stream that is being recorded and the recorder. This method explicitly closes the recorder only.
[ "Close", "both", "input", "and", "output", "recorders", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/Recorder.java#L262-L269
train
iipc/webarchive-commons
src/main/java/org/archive/util/Recorder.java
Recorder.delete
private void delete(String name) { File f = new File(name); if (f.exists()) { f.delete(); } }
java
private void delete(String name) { File f = new File(name); if (f.exists()) { f.delete(); } }
[ "private", "void", "delete", "(", "String", "name", ")", "{", "File", "f", "=", "new", "File", "(", "name", ")", ";", "if", "(", "f", ".", "exists", "(", ")", ")", "{", "f", ".", "delete", "(", ")", ";", "}", "}" ]
Delete file if exists. @param name Filename to delete.
[ "Delete", "file", "if", "exists", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/Recorder.java#L288-L293
train
iipc/webarchive-commons
src/main/java/org/archive/util/Recorder.java
Recorder.getContentReplayPrefixString
public String getContentReplayPrefixString(int size, Charset cs) { try { InputStreamReader isr = new InputStreamReader(getContentReplayInputStream(), cs); char[] chars = new char[size]; int count = isr.read(chars); isr.close(); if (count > 0) { ...
java
public String getContentReplayPrefixString(int size, Charset cs) { try { InputStreamReader isr = new InputStreamReader(getContentReplayInputStream(), cs); char[] chars = new char[size]; int count = isr.read(chars); isr.close(); if (count > 0) { ...
[ "public", "String", "getContentReplayPrefixString", "(", "int", "size", ",", "Charset", "cs", ")", "{", "try", "{", "InputStreamReader", "isr", "=", "new", "InputStreamReader", "(", "getContentReplayInputStream", "(", ")", ",", "cs", ")", ";", "char", "[", "]"...
Return a short prefix of the presumed-textual content as a String. @param size max length of String to return @return String prefix, or empty String (with logged exception) on any error
[ "Return", "a", "short", "prefix", "of", "the", "presumed", "-", "textual", "content", "as", "a", "String", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/Recorder.java#L509-L524
train
iipc/webarchive-commons
src/main/java/org/archive/util/Recorder.java
Recorder.wrapInputStreamWithHttpRecord
public static Recorder wrapInputStreamWithHttpRecord(File dir, String basename, InputStream in, String encoding) throws IOException { Recorder rec = new Recorder(dir, basename); if (encoding != null && encoding.length() > 0) { rec.setCharset(Charset.forName(encoding)); } ...
java
public static Recorder wrapInputStreamWithHttpRecord(File dir, String basename, InputStream in, String encoding) throws IOException { Recorder rec = new Recorder(dir, basename); if (encoding != null && encoding.length() > 0) { rec.setCharset(Charset.forName(encoding)); } ...
[ "public", "static", "Recorder", "wrapInputStreamWithHttpRecord", "(", "File", "dir", ",", "String", "basename", ",", "InputStream", "in", ",", "String", "encoding", ")", "throws", "IOException", "{", "Recorder", "rec", "=", "new", "Recorder", "(", "dir", ",", ...
Record the input stream for later playback by an extractor, etc. This is convenience method used to setup an artificial HttpRecorder scenario used in unit tests, etc. @param dir Directory to write backing file to. @param basename of what we're recording. @param in Stream to read. @param encoding Stream encoding. @throw...
[ "Record", "the", "input", "stream", "for", "later", "playback", "by", "an", "extractor", "etc", ".", "This", "is", "convenience", "method", "used", "to", "setup", "an", "artificial", "HttpRecorder", "scenario", "used", "in", "unit", "tests", "etc", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/Recorder.java#L554-L575
train
iipc/webarchive-commons
src/main/java/org/archive/io/warc/WARCWriter.java
WARCWriter.createRecordHeader
protected String createRecordHeader(WARCRecordInfo metaRecord) throws IllegalArgumentException { final StringBuilder sb = new StringBuilder(2048/*A SWAG: TODO: Do analysis.*/); sb.append(WARC_ID).append(CRLF); sb.append(HEADER_KEY_TYPE).append(COLON_SPACE).append(metaRecord.getType()). ...
java
protected String createRecordHeader(WARCRecordInfo metaRecord) throws IllegalArgumentException { final StringBuilder sb = new StringBuilder(2048/*A SWAG: TODO: Do analysis.*/); sb.append(WARC_ID).append(CRLF); sb.append(HEADER_KEY_TYPE).append(COLON_SPACE).append(metaRecord.getType()). ...
[ "protected", "String", "createRecordHeader", "(", "WARCRecordInfo", "metaRecord", ")", "throws", "IllegalArgumentException", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "2048", "/*A SWAG: TODO: Do analysis.*/", ")", ";", "sb", ".", "append", ...
final ANVLRecord xtraHeaders, final long contentLength)
[ "final", "ANVLRecord", "xtraHeaders", "final", "long", "contentLength", ")" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/warc/WARCWriter.java#L184-L214
train
iipc/webarchive-commons
src/main/java/org/archive/util/TextUtils.java
TextUtils.getMatcher
public static Matcher getMatcher(String pattern, CharSequence input) { if (pattern == null) { throw new IllegalArgumentException("String 'pattern' must not be null"); } input = new InterruptibleCharSequence(input); final Map<String,Matcher> matchers = TL_MATCHER_MAP.get(); ...
java
public static Matcher getMatcher(String pattern, CharSequence input) { if (pattern == null) { throw new IllegalArgumentException("String 'pattern' must not be null"); } input = new InterruptibleCharSequence(input); final Map<String,Matcher> matchers = TL_MATCHER_MAP.get(); ...
[ "public", "static", "Matcher", "getMatcher", "(", "String", "pattern", ",", "CharSequence", "input", ")", "{", "if", "(", "pattern", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"String 'pattern' must not be null\"", ")", ";", "}", ...
Get a matcher object for a precompiled regex pattern. This method tries to reuse Matcher objects for efficiency. It can hold for recycling one Matcher per pattern per thread. Matchers retrieved should be returned for reuse via the recycleMatcher() method, but no errors will occur if they are not. This method is a ho...
[ "Get", "a", "matcher", "object", "for", "a", "precompiled", "regex", "pattern", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/TextUtils.java#L80-L94
train
iipc/webarchive-commons
src/main/java/org/archive/util/TextUtils.java
TextUtils.replaceAll
public static String replaceAll( String pattern, CharSequence input, String replacement) { input = new InterruptibleCharSequence(input); Matcher m = getMatcher(pattern, input); String res = m.replaceAll(replacement); recycleMatcher(m); return res; }
java
public static String replaceAll( String pattern, CharSequence input, String replacement) { input = new InterruptibleCharSequence(input); Matcher m = getMatcher(pattern, input); String res = m.replaceAll(replacement); recycleMatcher(m); return res; }
[ "public", "static", "String", "replaceAll", "(", "String", "pattern", ",", "CharSequence", "input", ",", "String", "replacement", ")", "{", "input", "=", "new", "InterruptibleCharSequence", "(", "input", ")", ";", "Matcher", "m", "=", "getMatcher", "(", "patte...
Utility method using a precompiled pattern instead of using the replaceAll method of the String class. This method will also be reusing Matcher objects. @see java.util.regex.Pattern @param pattern precompiled Pattern to match against @param input the character sequence to check @param replacement the String to substit...
[ "Utility", "method", "using", "a", "precompiled", "pattern", "instead", "of", "using", "the", "replaceAll", "method", "of", "the", "String", "class", ".", "This", "method", "will", "also", "be", "reusing", "Matcher", "objects", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/TextUtils.java#L114-L121
train
iipc/webarchive-commons
src/main/java/org/archive/util/TextUtils.java
TextUtils.matches
public static boolean matches(String pattern, CharSequence input) { input = new InterruptibleCharSequence(input); Matcher m = getMatcher(pattern, input); boolean res = m.matches(); recycleMatcher(m); return res; }
java
public static boolean matches(String pattern, CharSequence input) { input = new InterruptibleCharSequence(input); Matcher m = getMatcher(pattern, input); boolean res = m.matches(); recycleMatcher(m); return res; }
[ "public", "static", "boolean", "matches", "(", "String", "pattern", ",", "CharSequence", "input", ")", "{", "input", "=", "new", "InterruptibleCharSequence", "(", "input", ")", ";", "Matcher", "m", "=", "getMatcher", "(", "pattern", ",", "input", ")", ";", ...
Utility method using a precompiled pattern instead of using the matches method of the String class. This method will also be reusing Matcher objects. @see java.util.regex.Pattern @param pattern precompiled Pattern to match against @param input the character sequence to check @return true if character sequence matches
[ "Utility", "method", "using", "a", "precompiled", "pattern", "instead", "of", "using", "the", "matches", "method", "of", "the", "String", "class", ".", "This", "method", "will", "also", "be", "reusing", "Matcher", "objects", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/TextUtils.java#L153-L159
train
iipc/webarchive-commons
src/main/java/org/archive/util/TextUtils.java
TextUtils.split
public static String[] split(String pattern, CharSequence input) { input = new InterruptibleCharSequence(input); Matcher m = getMatcher(pattern,input); String[] retVal = m.pattern().split(input); recycleMatcher(m); return retVal; }
java
public static String[] split(String pattern, CharSequence input) { input = new InterruptibleCharSequence(input); Matcher m = getMatcher(pattern,input); String[] retVal = m.pattern().split(input); recycleMatcher(m); return retVal; }
[ "public", "static", "String", "[", "]", "split", "(", "String", "pattern", ",", "CharSequence", "input", ")", "{", "input", "=", "new", "InterruptibleCharSequence", "(", "input", ")", ";", "Matcher", "m", "=", "getMatcher", "(", "pattern", ",", "input", ")...
Utility method using a precompiled pattern instead of using the split method of the String class. @see java.util.regex.Pattern @param pattern precompiled Pattern to split by @param input the character sequence to split @return array of Strings split by pattern
[ "Utility", "method", "using", "a", "precompiled", "pattern", "instead", "of", "using", "the", "split", "method", "of", "the", "String", "class", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/TextUtils.java#L170-L176
train
iipc/webarchive-commons
src/main/java/org/archive/util/TextUtils.java
TextUtils.unescapeHtml
public static CharSequence unescapeHtml(final CharSequence cs) { if (cs == null) { return cs; } return StringEscapeUtils.unescapeHtml(cs.toString()); }
java
public static CharSequence unescapeHtml(final CharSequence cs) { if (cs == null) { return cs; } return StringEscapeUtils.unescapeHtml(cs.toString()); }
[ "public", "static", "CharSequence", "unescapeHtml", "(", "final", "CharSequence", "cs", ")", "{", "if", "(", "cs", "==", "null", ")", "{", "return", "cs", ";", "}", "return", "StringEscapeUtils", ".", "unescapeHtml", "(", "cs", ".", "toString", "(", ")", ...
Replaces HTML Entity Encodings. @param cs The CharSequence to remove html codes from @return the same CharSequence or an escaped String.
[ "Replaces", "HTML", "Entity", "Encodings", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/TextUtils.java#L251-L257
train
iipc/webarchive-commons
src/main/java/org/archive/util/TextUtils.java
TextUtils.urlEscape
@SuppressWarnings("deprecation") public static String urlEscape(String s) { try { return URLEncoder.encode(s,"UTF8"); } catch (UnsupportedEncodingException e) { // should be impossible; all JVMs must support UTF8 // but have a fallback just in case ret...
java
@SuppressWarnings("deprecation") public static String urlEscape(String s) { try { return URLEncoder.encode(s,"UTF8"); } catch (UnsupportedEncodingException e) { // should be impossible; all JVMs must support UTF8 // but have a fallback just in case ret...
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "static", "String", "urlEscape", "(", "String", "s", ")", "{", "try", "{", "return", "URLEncoder", ".", "encode", "(", "s", ",", "\"UTF8\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingExce...
Exception- and warning-free URL-escaping utility method. @param s String to escape @return URL-escaped string
[ "Exception", "-", "and", "warning", "-", "free", "URL", "-", "escaping", "utility", "method", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/TextUtils.java#L282-L291
train
iipc/webarchive-commons
src/main/java/org/archive/util/TextUtils.java
TextUtils.urlUnescape
@SuppressWarnings("deprecation") public static String urlUnescape(String s) { try { return URLDecoder.decode(s, "UTF8"); } catch (UnsupportedEncodingException e) { // should be impossible; all JVMs must support UTF8 // but have a fallback just in case ...
java
@SuppressWarnings("deprecation") public static String urlUnescape(String s) { try { return URLDecoder.decode(s, "UTF8"); } catch (UnsupportedEncodingException e) { // should be impossible; all JVMs must support UTF8 // but have a fallback just in case ...
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "public", "static", "String", "urlUnescape", "(", "String", "s", ")", "{", "try", "{", "return", "URLDecoder", ".", "decode", "(", "s", ",", "\"UTF8\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingEx...
Exception- and warning-free URL-unescaping utility method. @param s String do unescape @return URL-unescaped String
[ "Exception", "-", "and", "warning", "-", "free", "URL", "-", "unescaping", "utility", "method", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/TextUtils.java#L299-L308
train
iipc/webarchive-commons
src/main/java/org/archive/util/PrefixSet.java
PrefixSet.containsPrefixOf
public boolean containsPrefixOf(String s) { SortedSet<String> sub = headSet(s); // because redundant prefixes have been eliminated, // only a test against last item in headSet is necessary if (!sub.isEmpty() && s.startsWith((String)sub.last())) { return true; // prefix s...
java
public boolean containsPrefixOf(String s) { SortedSet<String> sub = headSet(s); // because redundant prefixes have been eliminated, // only a test against last item in headSet is necessary if (!sub.isEmpty() && s.startsWith((String)sub.last())) { return true; // prefix s...
[ "public", "boolean", "containsPrefixOf", "(", "String", "s", ")", "{", "SortedSet", "<", "String", ">", "sub", "=", "headSet", "(", "s", ")", ";", "// because redundant prefixes have been eliminated,\r", "// only a test against last item in headSet is necessary\r", "if", ...
Test whether the given String is prefixed by one of this set's entries. @param s @return True if contains prefix.
[ "Test", "whether", "the", "given", "String", "is", "prefixed", "by", "one", "of", "this", "set", "s", "entries", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/PrefixSet.java#L43-L51
train
iipc/webarchive-commons
src/main/java/org/archive/util/DevUtils.java
DevUtils.warnHandle
public static void warnHandle(Throwable ex, String note) { logger.warning(TextUtils.exceptionToString(note, ex)); }
java
public static void warnHandle(Throwable ex, String note) { logger.warning(TextUtils.exceptionToString(note, ex)); }
[ "public", "static", "void", "warnHandle", "(", "Throwable", "ex", ",", "String", "note", ")", "{", "logger", ".", "warning", "(", "TextUtils", ".", "exceptionToString", "(", "note", ",", "ex", ")", ")", ";", "}" ]
Log a warning message to the logger 'org.archive.util.DevUtils' made of the passed 'note' and a stack trace based off passed exception. @param ex Exception we print a stacktrace on. @param note Message to print ahead of the stacktrace.
[ "Log", "a", "warning", "message", "to", "the", "logger", "org", ".", "archive", ".", "util", ".", "DevUtils", "made", "of", "the", "passed", "note", "and", "a", "stack", "trace", "based", "off", "passed", "exception", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/DevUtils.java#L46-L48
train
iipc/webarchive-commons
src/main/java/org/archive/util/MimetypeUtils.java
MimetypeUtils.truncate
public static String truncate(String contentType) { if (contentType == null) { contentType = NO_TYPE_MIMETYPE; } else { Matcher matcher = TRUNCATION_REGEX.matcher(contentType); if (matcher.matches()) { contentType = matcher.group(1); } else { ...
java
public static String truncate(String contentType) { if (contentType == null) { contentType = NO_TYPE_MIMETYPE; } else { Matcher matcher = TRUNCATION_REGEX.matcher(contentType); if (matcher.matches()) { contentType = matcher.group(1); } else { ...
[ "public", "static", "String", "truncate", "(", "String", "contentType", ")", "{", "if", "(", "contentType", "==", "null", ")", "{", "contentType", "=", "NO_TYPE_MIMETYPE", ";", "}", "else", "{", "Matcher", "matcher", "=", "TRUNCATION_REGEX", ".", "matcher", ...
Truncate passed mimetype. Ensure no spaces. Strip encoding. Truncation required by ARC files. <p>Truncate at delimiters [;, ]. Truncate multi-part content type header at ';'. Apache httpclient collapses values of multiple instances of the header into one comma-separated value,therefore truncated at ','. Current ia_...
[ "Truncate", "passed", "mimetype", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/MimetypeUtils.java#L61-L74
train
iipc/webarchive-commons
src/main/java/org/archive/io/Endian.java
Endian.littleChar
public static char littleChar(InputStream input) throws IOException { int lo = input.read(); if (lo < 0) { throw new EOFException(); } int hi = input.read(); if (hi < 0) { throw new EOFException(); } return (char)((hi << 8) | lo); }
java
public static char littleChar(InputStream input) throws IOException { int lo = input.read(); if (lo < 0) { throw new EOFException(); } int hi = input.read(); if (hi < 0) { throw new EOFException(); } return (char)((hi << 8) | lo); }
[ "public", "static", "char", "littleChar", "(", "InputStream", "input", ")", "throws", "IOException", "{", "int", "lo", "=", "input", ".", "read", "(", ")", ";", "if", "(", "lo", "<", "0", ")", "{", "throw", "new", "EOFException", "(", ")", ";", "}", ...
Reads the next little-endian unsigned 16 bit integer from the given stream. @param input the input stream to read from @return the next 16-bit little-endian integer @throws IOException if an IO error occurs
[ "Reads", "the", "next", "little", "-", "endian", "unsigned", "16", "bit", "integer", "from", "the", "given", "stream", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/Endian.java#L50-L60
train
iipc/webarchive-commons
src/main/java/org/archive/io/Endian.java
Endian.littleInt
public static int littleInt(InputStream input) throws IOException { char lo = littleChar(input); char hi = littleChar(input); return (hi << 16) | lo; }
java
public static int littleInt(InputStream input) throws IOException { char lo = littleChar(input); char hi = littleChar(input); return (hi << 16) | lo; }
[ "public", "static", "int", "littleInt", "(", "InputStream", "input", ")", "throws", "IOException", "{", "char", "lo", "=", "littleChar", "(", "input", ")", ";", "char", "hi", "=", "littleChar", "(", "input", ")", ";", "return", "(", "hi", "<<", "16", "...
Reads the next little-endian signed 32-bit integer from the given stream. @param input the input stream to read from @return the next 32-bit little-endian integer @throws IOException if an IO error occurs
[ "Reads", "the", "next", "little", "-", "endian", "signed", "32", "-", "bit", "integer", "from", "the", "given", "stream", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/Endian.java#L84-L88
train
iipc/webarchive-commons
src/main/java/org/archive/io/Endian.java
Endian.bigChar
public static char bigChar(InputStream input) throws IOException { int hi = input.read(); if (hi < 0) { throw new EOFException(); } int lo = input.read(); if (lo < 0) { throw new EOFException(); } return (char)((hi << 8) | lo); }
java
public static char bigChar(InputStream input) throws IOException { int hi = input.read(); if (hi < 0) { throw new EOFException(); } int lo = input.read(); if (lo < 0) { throw new EOFException(); } return (char)((hi << 8) | lo); }
[ "public", "static", "char", "bigChar", "(", "InputStream", "input", ")", "throws", "IOException", "{", "int", "hi", "=", "input", ".", "read", "(", ")", ";", "if", "(", "hi", "<", "0", ")", "{", "throw", "new", "EOFException", "(", ")", ";", "}", "...
Reads the next big-endian unsigned 16 bit integer from the given stream. @param input the input stream to read from @return the next 16-bit big-endian integer @throws IOException if an IO error occurs
[ "Reads", "the", "next", "big", "-", "endian", "unsigned", "16", "bit", "integer", "from", "the", "given", "stream", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/Endian.java#L99-L109
train
iipc/webarchive-commons
src/main/java/org/archive/io/Endian.java
Endian.bigInt
public static int bigInt(InputStream input) throws IOException { char hi = bigChar(input); char lo = bigChar(input); return (hi << 16) | lo; }
java
public static int bigInt(InputStream input) throws IOException { char hi = bigChar(input); char lo = bigChar(input); return (hi << 16) | lo; }
[ "public", "static", "int", "bigInt", "(", "InputStream", "input", ")", "throws", "IOException", "{", "char", "hi", "=", "bigChar", "(", "input", ")", ";", "char", "lo", "=", "bigChar", "(", "input", ")", ";", "return", "(", "hi", "<<", "16", ")", "|"...
Reads the next big-endian signed 32-bit integer from the given stream. @param input the input stream to read from @return the next 32-bit big-endian integer @throws IOException if an IO error occurs
[ "Reads", "the", "next", "big", "-", "endian", "signed", "32", "-", "bit", "integer", "from", "the", "given", "stream", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/Endian.java#L120-L124
train
iipc/webarchive-commons
src/main/java/org/archive/io/ObjectPlusFilesInputStream.java
ObjectPlusFilesInputStream.restoreFile
public void restoreFile(File destination) throws IOException { String nameAsStored = readUTF(); long lengthAtStoreTime = readLong(); File storedFile = new File(getAuxiliaryDirectory(),nameAsStored); FileUtils.copyFile(storedFile, destination, lengthAtStoreTime); }
java
public void restoreFile(File destination) throws IOException { String nameAsStored = readUTF(); long lengthAtStoreTime = readLong(); File storedFile = new File(getAuxiliaryDirectory(),nameAsStored); FileUtils.copyFile(storedFile, destination, lengthAtStoreTime); }
[ "public", "void", "restoreFile", "(", "File", "destination", ")", "throws", "IOException", "{", "String", "nameAsStored", "=", "readUTF", "(", ")", ";", "long", "lengthAtStoreTime", "=", "readLong", "(", ")", ";", "File", "storedFile", "=", "new", "File", "(...
Restore a file from storage, using the name and length info on the serialization stream and the file from the current auxiliary directory, to the given File. @param destination @throws IOException
[ "Restore", "a", "file", "from", "storage", "using", "the", "name", "and", "length", "info", "on", "the", "serialization", "stream", "and", "the", "file", "from", "the", "current", "auxiliary", "directory", "to", "the", "given", "File", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/ObjectPlusFilesInputStream.java#L94-L99
train
iipc/webarchive-commons
src/main/java/org/archive/io/arc/ARCRecord.java
ARCRecord.getTokenizedHeaderLine
private int getTokenizedHeaderLine(final InputStream stream, List<String> list) throws IOException { // Preallocate usual line size. StringBuilder buffer = new StringBuilder(2048 + 20); int read = 0; int previous = -1; for (int c = -1; true;) { previou...
java
private int getTokenizedHeaderLine(final InputStream stream, List<String> list) throws IOException { // Preallocate usual line size. StringBuilder buffer = new StringBuilder(2048 + 20); int read = 0; int previous = -1; for (int c = -1; true;) { previou...
[ "private", "int", "getTokenizedHeaderLine", "(", "final", "InputStream", "stream", ",", "List", "<", "String", ">", "list", ")", "throws", "IOException", "{", "// Preallocate usual line size.", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", "2048", "+"...
Get a record header line as list of tokens. We keep reading till we find a LINE_SEPARATOR or we reach the end of file w/o finding a LINE_SEPARATOR or the line length is crazy. @param stream InputStream to read from. @param list Empty list that gets filled w/ string tokens. @return Count of characters read. @exception...
[ "Get", "a", "record", "header", "line", "as", "list", "of", "tokens", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/arc/ARCRecord.java#L292-L351
train
iipc/webarchive-commons
src/main/java/org/archive/io/arc/ARCRecord.java
ARCRecord.skipHttpHeader
public void skipHttpHeader() throws IOException { if (this.httpHeaderStream != null) { // Empty the httpHeaderStream for (int available = this.httpHeaderStream.available(); this.httpHeaderStream != null && (available = this.httpHead...
java
public void skipHttpHeader() throws IOException { if (this.httpHeaderStream != null) { // Empty the httpHeaderStream for (int available = this.httpHeaderStream.available(); this.httpHeaderStream != null && (available = this.httpHead...
[ "public", "void", "skipHttpHeader", "(", ")", "throws", "IOException", "{", "if", "(", "this", ".", "httpHeaderStream", "!=", "null", ")", "{", "// Empty the httpHeaderStream", "for", "(", "int", "available", "=", "this", ".", "httpHeaderStream", ".", "available...
Skip over the the http header if one present. Subsequent reads will get the body. <p>Calling this method in the midst of reading the header will make for strange results. Otherwise, safe to call at any time though before reading any of the arc record content is only time that it makes sense. <p>After calling this m...
[ "Skip", "over", "the", "the", "http", "header", "if", "one", "present", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/arc/ARCRecord.java#L521-L535
train
iipc/webarchive-commons
src/main/java/org/archive/url/UsableURIFactory.java
UsableURIFactory.validityCheck
protected UsableURI validityCheck(UsableURI uuri) throws URIException { if (uuri.getRawURI().length > UsableURI.MAX_URL_LENGTH) { throw new URIException("Created (escaped) uuri > " + UsableURI.MAX_URL_LENGTH +": "+uuri.toString()); } return uuri; }
java
protected UsableURI validityCheck(UsableURI uuri) throws URIException { if (uuri.getRawURI().length > UsableURI.MAX_URL_LENGTH) { throw new URIException("Created (escaped) uuri > " + UsableURI.MAX_URL_LENGTH +": "+uuri.toString()); } return uuri; }
[ "protected", "UsableURI", "validityCheck", "(", "UsableURI", "uuri", ")", "throws", "URIException", "{", "if", "(", "uuri", ".", "getRawURI", "(", ")", ".", "length", ">", "UsableURI", ".", "MAX_URL_LENGTH", ")", "{", "throw", "new", "URIException", "(", "\"...
Check the generated UURI. At the least look at length of uuri string. We were seeing case where before escaping, string was &lt; MAX_URL_LENGTH but after was &gt;. Letting out a too-big message was causing us troubles later down the processing chain. @param uuri Created uuri to check. @return The passed <code>uuri</...
[ "Check", "the", "generated", "UURI", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/url/UsableURIFactory.java#L324-L330
train
iipc/webarchive-commons
src/main/java/org/archive/url/UsableURIFactory.java
UsableURIFactory.fixupAuthority
private String fixupAuthority(String uriAuthority, String charset) throws URIException { // Lowercase the host part of the uriAuthority; don't destroy any // userinfo capitalizations. Make sure no illegal characters in // domainlabel substring of the uri authority. if (uriAuthority != n...
java
private String fixupAuthority(String uriAuthority, String charset) throws URIException { // Lowercase the host part of the uriAuthority; don't destroy any // userinfo capitalizations. Make sure no illegal characters in // domainlabel substring of the uri authority. if (uriAuthority != n...
[ "private", "String", "fixupAuthority", "(", "String", "uriAuthority", ",", "String", "charset", ")", "throws", "URIException", "{", "// Lowercase the host part of the uriAuthority; don't destroy any", "// userinfo capitalizations. Make sure no illegal characters in", "// domainlabel s...
Fixup 'authority' portion of URI, by removing any stray encoded spaces, lowercasing any domain names, and applying IDN-punycoding to Unicode domains. @param uriAuthority the authority string to fix @return fixed version @throws URIException
[ "Fixup", "authority", "portion", "of", "URI", "by", "removing", "any", "stray", "encoded", "spaces", "lowercasing", "any", "domain", "names", "and", "applying", "IDN", "-", "punycoding", "to", "Unicode", "domains", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/url/UsableURIFactory.java#L545-L583
train
iipc/webarchive-commons
src/main/java/org/archive/url/UsableURIFactory.java
UsableURIFactory.fixupDomainlabel
private String fixupDomainlabel(String label) throws URIException { // apply IDN-punycoding, as necessary try { // TODO: optimize: only apply when necessary, or // keep cache of recent encodings label = IDNA.toASCII(label); } catch (IDNAException ...
java
private String fixupDomainlabel(String label) throws URIException { // apply IDN-punycoding, as necessary try { // TODO: optimize: only apply when necessary, or // keep cache of recent encodings label = IDNA.toASCII(label); } catch (IDNAException ...
[ "private", "String", "fixupDomainlabel", "(", "String", "label", ")", "throws", "URIException", "{", "// apply IDN-punycoding, as necessary", "try", "{", "// TODO: optimize: only apply when necessary, or", "// keep cache of recent encodings", "label", "=", "IDNA", ".", "toASCII...
Fixup the domain label part of the authority. We're more lax than the spec. in that we allow underscores. @param label Domain label to fix. @return Return fixed domain label. @throws URIException
[ "Fixup", "the", "domain", "label", "part", "of", "the", "authority", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/url/UsableURIFactory.java#L594-L619
train
iipc/webarchive-commons
src/main/java/org/archive/io/arc/ARCReader.java
ARCReader.createArchiveRecord
protected ARCRecord createArchiveRecord(InputStream is, long offset) throws IOException { try { String version = super.getVersion(); ARCRecord record = new ARCRecord(is, getReaderIdentifier(), offset, isDigest(), isStrict(), isParseHttpHeaders(), ...
java
protected ARCRecord createArchiveRecord(InputStream is, long offset) throws IOException { try { String version = super.getVersion(); ARCRecord record = new ARCRecord(is, getReaderIdentifier(), offset, isDigest(), isStrict(), isParseHttpHeaders(), ...
[ "protected", "ARCRecord", "createArchiveRecord", "(", "InputStream", "is", ",", "long", "offset", ")", "throws", "IOException", "{", "try", "{", "String", "version", "=", "super", ".", "getVersion", "(", ")", ";", "ARCRecord", "record", "=", "new", "ARCRecord"...
Create new arc record. Encapsulate housekeeping that has to do w/ creating a new record. <p>Call this method at end of constructor to read in the arcfile header. Will be problems reading subsequent arc records if you don't since arcfile header has the list of metadata fields for all records that follow. <p>When par...
[ "Create", "new", "arc", "record", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/arc/ARCReader.java#L145-L166
train
iipc/webarchive-commons
src/main/java/org/archive/net/PublicSuffixes.java
PublicSuffixes.dump
public static void dump(Node alt, int lv, PrintWriter out) { for (int i = 0; i < lv; i++) out.print(" "); out.println(alt.cs != null ? ('"'+alt.cs.toString()+'"') : "(null)"); if (alt.branches != null) { for (Node br : alt.branches) { dump(br, lv + 1, out...
java
public static void dump(Node alt, int lv, PrintWriter out) { for (int i = 0; i < lv; i++) out.print(" "); out.println(alt.cs != null ? ('"'+alt.cs.toString()+'"') : "(null)"); if (alt.branches != null) { for (Node br : alt.branches) { dump(br, lv + 1, out...
[ "public", "static", "void", "dump", "(", "Node", "alt", ",", "int", "lv", ",", "PrintWriter", "out", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "lv", ";", "i", "++", ")", "out", ".", "print", "(", "\" \"", ")", ";", "out", "....
utility function for dumping prefix tree structure. intended for debug use. @param alt root of prefix tree. @param lv indent level. 0 for root (no indent). @param out writer to send output to.
[ "utility", "function", "for", "dumping", "prefix", "tree", "structure", ".", "intended", "for", "debug", "use", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/net/PublicSuffixes.java#L240-L249
train
iipc/webarchive-commons
src/main/java/org/archive/net/PublicSuffixes.java
PublicSuffixes.reduceSurtToAssignmentLevel
public static String reduceSurtToAssignmentLevel(String surt) { Matcher matcher = TextUtils.getMatcher( getTopmostAssignedSurtPrefixRegex(), surt); if (matcher.find()) { surt = matcher.group(); } TextUtils.recycleMatcher(matcher); return surt; }
java
public static String reduceSurtToAssignmentLevel(String surt) { Matcher matcher = TextUtils.getMatcher( getTopmostAssignedSurtPrefixRegex(), surt); if (matcher.find()) { surt = matcher.group(); } TextUtils.recycleMatcher(matcher); return surt; }
[ "public", "static", "String", "reduceSurtToAssignmentLevel", "(", "String", "surt", ")", "{", "Matcher", "matcher", "=", "TextUtils", ".", "getMatcher", "(", "getTopmostAssignedSurtPrefixRegex", "(", ")", ",", "surt", ")", ";", "if", "(", "matcher", ".", "find",...
Truncate SURT to its topmost assigned domain segment; that is, the public suffix plus one segment, but as a SURT-ordered prefix. if the pattern doesn't match, the passed-in SURT is returned. @param surt SURT to truncate @return truncated-to-topmost-assigned SURT prefix
[ "Truncate", "SURT", "to", "its", "topmost", "assigned", "domain", "segment", ";", "that", "is", "the", "public", "suffix", "plus", "one", "segment", "but", "as", "a", "SURT", "-", "ordered", "prefix", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/net/PublicSuffixes.java#L354-L362
train
iipc/webarchive-commons
src/main/java/org/archive/io/BufferedSeekInputStream.java
BufferedSeekInputStream.buffer
private void buffer() throws IOException { int remaining = buffer.length; while (remaining > 0) { int r = input.read(buffer, buffer.length - remaining, remaining); if (r <= 0) { // Not enough information to fill the buffer offset = 0; ...
java
private void buffer() throws IOException { int remaining = buffer.length; while (remaining > 0) { int r = input.read(buffer, buffer.length - remaining, remaining); if (r <= 0) { // Not enough information to fill the buffer offset = 0; ...
[ "private", "void", "buffer", "(", ")", "throws", "IOException", "{", "int", "remaining", "=", "buffer", ".", "length", ";", "while", "(", "remaining", ">", "0", ")", "{", "int", "r", "=", "input", ".", "read", "(", "buffer", ",", "buffer", ".", "leng...
Fills the buffer. @throws IOException if an IO error occurs
[ "Fills", "the", "buffer", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/BufferedSeekInputStream.java#L78-L92
train
iipc/webarchive-commons
src/main/java/org/archive/io/BufferedSeekInputStream.java
BufferedSeekInputStream.position
public void position(long p) throws IOException { long blockStart = (input.position() - maxOffset) / buffer.length * buffer.length; long blockEnd = blockStart + maxOffset; if ((p >= blockStart) && (p < blockEnd)) { // Desired position is somewhere inside current buffer ...
java
public void position(long p) throws IOException { long blockStart = (input.position() - maxOffset) / buffer.length * buffer.length; long blockEnd = blockStart + maxOffset; if ((p >= blockStart) && (p < blockEnd)) { // Desired position is somewhere inside current buffer ...
[ "public", "void", "position", "(", "long", "p", ")", "throws", "IOException", "{", "long", "blockStart", "=", "(", "input", ".", "position", "(", ")", "-", "maxOffset", ")", "/", "buffer", ".", "length", "*", "buffer", ".", "length", ";", "long", "bloc...
Seeks to the given position. This method avoids re-filling the buffer if at all possible. @param p the position to set @throws IOException if an IO error occurs
[ "Seeks", "to", "the", "given", "position", ".", "This", "method", "avoids", "re", "-", "filling", "the", "buffer", "if", "at", "all", "possible", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/BufferedSeekInputStream.java#L178-L189
train
iipc/webarchive-commons
src/main/java/org/archive/io/BufferedSeekInputStream.java
BufferedSeekInputStream.positionDirect
private void positionDirect(long p) throws IOException { long newBlockStart = p / buffer.length * buffer.length; input.position(newBlockStart); buffer(); offset = (int)(p % buffer.length); }
java
private void positionDirect(long p) throws IOException { long newBlockStart = p / buffer.length * buffer.length; input.position(newBlockStart); buffer(); offset = (int)(p % buffer.length); }
[ "private", "void", "positionDirect", "(", "long", "p", ")", "throws", "IOException", "{", "long", "newBlockStart", "=", "p", "/", "buffer", ".", "length", "*", "buffer", ".", "length", ";", "input", ".", "position", "(", "newBlockStart", ")", ";", "buffer"...
Positions the underlying stream at the given position, then refills the buffer. @param p the position to set @throws IOException if an IO error occurs
[ "Positions", "the", "underlying", "stream", "at", "the", "given", "position", "then", "refills", "the", "buffer", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/BufferedSeekInputStream.java#L199-L204
train
iipc/webarchive-commons
src/main/java/org/archive/io/ArchiveReader.java
ArchiveReader.getInputStream
protected InputStream getInputStream(final File f, final long offset) throws IOException { FileInputStream fin = new FileInputStream(f); return new BufferedInputStream(fin); }
java
protected InputStream getInputStream(final File f, final long offset) throws IOException { FileInputStream fin = new FileInputStream(f); return new BufferedInputStream(fin); }
[ "protected", "InputStream", "getInputStream", "(", "final", "File", "f", ",", "final", "long", "offset", ")", "throws", "IOException", "{", "FileInputStream", "fin", "=", "new", "FileInputStream", "(", "f", ")", ";", "return", "new", "BufferedInputStream", "(", ...
Convenience method for constructors. @param f File to read. @param offset Offset at which to start reading. @return InputStream to read from. @throws IOException If failed open or fail to get a memory mapped byte buffer on file.
[ "Convenience", "method", "for", "constructors", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/ArchiveReader.java#L126-L130
train
iipc/webarchive-commons
src/main/java/org/archive/io/ArchiveReader.java
ArchiveReader.cleanupCurrentRecord
protected void cleanupCurrentRecord() throws IOException { if (this.currentRecord != null) { this.currentRecord.close(); gotoEOR(this.currentRecord); this.currentRecord = null; } }
java
protected void cleanupCurrentRecord() throws IOException { if (this.currentRecord != null) { this.currentRecord.close(); gotoEOR(this.currentRecord); this.currentRecord = null; } }
[ "protected", "void", "cleanupCurrentRecord", "(", ")", "throws", "IOException", "{", "if", "(", "this", ".", "currentRecord", "!=", "null", ")", "{", "this", ".", "currentRecord", ".", "close", "(", ")", ";", "gotoEOR", "(", "this", ".", "currentRecord", "...
Cleanout the current record if there is one. @throws IOException
[ "Cleanout", "the", "current", "record", "if", "there", "is", "one", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/ArchiveReader.java#L173-L179
train
iipc/webarchive-commons
src/main/java/org/archive/io/ArchiveReader.java
ArchiveReader.validate
public List<ArchiveRecordHeader> validate(int numRecords) throws IOException { List<ArchiveRecordHeader> hdrList = new ArrayList<ArchiveRecordHeader>(); int recordCount = 0; setStrict(true); for (Iterator<ArchiveRecord> i = iterator(); i.hasNext();) { recordCount++; ...
java
public List<ArchiveRecordHeader> validate(int numRecords) throws IOException { List<ArchiveRecordHeader> hdrList = new ArrayList<ArchiveRecordHeader>(); int recordCount = 0; setStrict(true); for (Iterator<ArchiveRecord> i = iterator(); i.hasNext();) { recordCount++; ...
[ "public", "List", "<", "ArchiveRecordHeader", ">", "validate", "(", "int", "numRecords", ")", "throws", "IOException", "{", "List", "<", "ArchiveRecordHeader", ">", "hdrList", "=", "new", "ArrayList", "<", "ArchiveRecordHeader", ">", "(", ")", ";", "int", "rec...
Validate the Archive file. This method iterates over the file throwing exception if it fails to successfully parse. <p>We start validation from wherever we are in the stream. @param numRecords Number of records expected. Pass -1 if number is unknown. @return List of all read metadatas. As we validate records, we a...
[ "Validate", "the", "Archive", "file", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/ArchiveReader.java#L242-L269
train
iipc/webarchive-commons
src/main/java/org/archive/io/ArchiveReader.java
ArchiveReader.isValid
public boolean isValid() { boolean valid = false; try { validate(); valid = true; } catch(Exception e) { // File is not valid if exception thrown parsing. valid = false; } return valid; }
java
public boolean isValid() { boolean valid = false; try { validate(); valid = true; } catch(Exception e) { // File is not valid if exception thrown parsing. valid = false; } return valid; }
[ "public", "boolean", "isValid", "(", ")", "{", "boolean", "valid", "=", "false", ";", "try", "{", "validate", "(", ")", ";", "valid", "=", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// File is not valid if exception thrown parsing.", "valid...
Test Archive file is valid. Assumes the stream is at the start of the file. Be aware that this method makes a pass over the whole file. @return True if file can be successfully parsed.
[ "Test", "Archive", "file", "is", "valid", ".", "Assumes", "the", "stream", "is", "at", "the", "start", "of", "the", "file", ".", "Be", "aware", "that", "this", "method", "makes", "a", "pass", "over", "the", "whole", "file", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/ArchiveReader.java#L277-L288
train
iipc/webarchive-commons
src/main/java/org/archive/io/ArchiveReader.java
ArchiveReader.logStdErr
public void logStdErr(Level level, String message) { System.err.println(level.toString() + " " + message); }
java
public void logStdErr(Level level, String message) { System.err.println(level.toString() + " " + message); }
[ "public", "void", "logStdErr", "(", "Level", "level", ",", "String", "message", ")", "{", "System", ".", "err", ".", "println", "(", "level", ".", "toString", "(", ")", "+", "\" \"", "+", "message", ")", ";", "}" ]
Log on stderr. Logging should go via the logging system. This method bypasses the logging system going direct to stderr. Should not generally be used. Its used for rare messages that come of cmdline usage of ARCReader ERRORs and WARNINGs. Override if using ARCReader in a context where no stderr or where you'd like to...
[ "Log", "on", "stderr", ".", "Logging", "should", "go", "via", "the", "logging", "system", ".", "This", "method", "bypasses", "the", "logging", "system", "going", "direct", "to", "stderr", ".", "Should", "not", "generally", "be", "used", ".", "Its", "used",...
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/ArchiveReader.java#L389-L391
train
iipc/webarchive-commons
src/main/java/org/archive/format/gzip/GZIPDecoder.java
GZIPDecoder.alignOnMagic3
public long alignOnMagic3(InputStream is) throws IOException { long bytesSkipped = 0; byte lookahead[] = new byte[3]; int keep = 0; while(true) { if(keep == 2) { lookahead[0] = lookahead[1]; lookahead[1] = lookahead[2]; } else if(keep == 1) { lookahead[0] = lookahead[2]; } int amt...
java
public long alignOnMagic3(InputStream is) throws IOException { long bytesSkipped = 0; byte lookahead[] = new byte[3]; int keep = 0; while(true) { if(keep == 2) { lookahead[0] = lookahead[1]; lookahead[1] = lookahead[2]; } else if(keep == 1) { lookahead[0] = lookahead[2]; } int amt...
[ "public", "long", "alignOnMagic3", "(", "InputStream", "is", ")", "throws", "IOException", "{", "long", "bytesSkipped", "=", "0", ";", "byte", "lookahead", "[", "]", "=", "new", "byte", "[", "3", "]", ";", "int", "keep", "=", "0", ";", "while", "(", ...
Read bytes from InputStream argument until 3 bytes are found that appear to be the start of a GZIPHeader. leave the stream on the 4th byte, and return the number of bytes skipped before finding the 3 bytes. @param is InputStream to read from @return number of bytes skipped before finding the gzip magic: 0 if the first...
[ "Read", "bytes", "from", "InputStream", "argument", "until", "3", "bytes", "are", "found", "that", "appear", "to", "be", "the", "start", "of", "a", "GZIPHeader", ".", "leave", "the", "stream", "on", "the", "4th", "byte", "and", "return", "the", "number", ...
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/format/gzip/GZIPDecoder.java#L43-L122
train
iipc/webarchive-commons
src/main/java/org/archive/io/warc/WARCReader.java
WARCReader.output
protected static void output(WARCReader reader, String format) throws IOException, java.text.ParseException { if (!reader.output(format)) { throw new IOException("Unsupported format: " + format); } }
java
protected static void output(WARCReader reader, String format) throws IOException, java.text.ParseException { if (!reader.output(format)) { throw new IOException("Unsupported format: " + format); } }
[ "protected", "static", "void", "output", "(", "WARCReader", "reader", ",", "String", "format", ")", "throws", "IOException", ",", "java", ".", "text", ".", "ParseException", "{", "if", "(", "!", "reader", ".", "output", "(", "format", ")", ")", "{", "thr...
Write out the arcfile. @param reader @param format Format to use outputting. @throws IOException @throws java.text.ParseException
[ "Write", "out", "the", "arcfile", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/warc/WARCReader.java#L151-L156
train
iipc/webarchive-commons
src/main/java/org/archive/util/iterator/RegexLineIterator.java
RegexLineIterator.transform
protected String transform(String line) { ignoreLine.reset(line); if(ignoreLine.matches()) { return null; } extractLine.reset(line); if(extractLine.matches()) { StringBuffer output = new StringBuffer(); // TODO: consider if a loop that find()s...
java
protected String transform(String line) { ignoreLine.reset(line); if(ignoreLine.matches()) { return null; } extractLine.reset(line); if(extractLine.matches()) { StringBuffer output = new StringBuffer(); // TODO: consider if a loop that find()s...
[ "protected", "String", "transform", "(", "String", "line", ")", "{", "ignoreLine", ".", "reset", "(", "line", ")", ";", "if", "(", "ignoreLine", ".", "matches", "(", ")", ")", "{", "return", "null", ";", "}", "extractLine", ".", "reset", "(", "line", ...
Loads next item into lookahead spot, if available. Skips lines matching ignoreLine; extracts desired portion of lines matching extractLine; informationally reports any lines matching neither. @return whether any item was loaded into next field
[ "Loads", "next", "item", "into", "lookahead", "spot", "if", "available", ".", "Skips", "lines", "matching", "ignoreLine", ";", "extracts", "desired", "portion", "of", "lines", "matching", "extractLine", ";", "informationally", "reports", "any", "lines", "matching"...
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/util/iterator/RegexLineIterator.java#L74-L90
train
iipc/webarchive-commons
src/main/java/org/archive/url/LaxURI.java
LaxURI.decode
protected static String decode(String component, String charset) throws URIException { if (component == null) { throw new IllegalArgumentException( "Component array of chars may not be null"); } byte[] rawdata = null; // try { rawda...
java
protected static String decode(String component, String charset) throws URIException { if (component == null) { throw new IllegalArgumentException( "Component array of chars may not be null"); } byte[] rawdata = null; // try { rawda...
[ "protected", "static", "String", "decode", "(", "String", "component", ",", "String", "charset", ")", "throws", "URIException", "{", "if", "(", "component", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Component array of chars may not ...
overridden to use IA's LaxURLCodec, which never throws DecoderException
[ "overridden", "to", "use", "IA", "s", "LaxURLCodec", "which", "never", "throws", "DecoderException" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/url/LaxURI.java#L117-L131
train
iipc/webarchive-commons
src/main/java/org/archive/url/LaxURI.java
LaxURI.parseAuthority
protected void parseAuthority(String original, boolean escaped) throws URIException { super.parseAuthority(original, escaped); if (_host != null && _authority != null && _host.length == _authority.length) { _host = _authority; } }
java
protected void parseAuthority(String original, boolean escaped) throws URIException { super.parseAuthority(original, escaped); if (_host != null && _authority != null && _host.length == _authority.length) { _host = _authority; } }
[ "protected", "void", "parseAuthority", "(", "String", "original", ",", "boolean", "escaped", ")", "throws", "URIException", "{", "super", ".", "parseAuthority", "(", "original", ",", "escaped", ")", ";", "if", "(", "_host", "!=", "null", "&&", "_authority", ...
Coalesce the _host and _authority fields where possible. In the web crawl/http domain, most URIs have an identical _host and _authority. (There is no port or user info.) However, the superclass always creates two separate char[] instances. Notably, the lengths of these char[] fields are equal if and only if their val...
[ "Coalesce", "the", "_host", "and", "_authority", "fields", "where", "possible", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/url/LaxURI.java#L188-L195
train
iipc/webarchive-commons
src/main/java/org/archive/url/LaxURI.java
LaxURI.setURI
protected void setURI() { if (_scheme != null) { if (_scheme.length == 4 && Arrays.equals(_scheme, HTTP_SCHEME)) { _scheme = HTTP_SCHEME; } else if (_scheme.length == 5 && Arrays.equals(_scheme, HTTPS_SCHEME)) { _scheme = HTTPS_SCHEME; ...
java
protected void setURI() { if (_scheme != null) { if (_scheme.length == 4 && Arrays.equals(_scheme, HTTP_SCHEME)) { _scheme = HTTP_SCHEME; } else if (_scheme.length == 5 && Arrays.equals(_scheme, HTTPS_SCHEME)) { _scheme = HTTPS_SCHEME; ...
[ "protected", "void", "setURI", "(", ")", "{", "if", "(", "_scheme", "!=", "null", ")", "{", "if", "(", "_scheme", ".", "length", "==", "4", "&&", "Arrays", ".", "equals", "(", "_scheme", ",", "HTTP_SCHEME", ")", ")", "{", "_scheme", "=", "HTTP_SCHEME...
Coalesce _scheme to existing instances, where appropriate. In the web-crawl domain, most _schemes are 'http' or 'https', but the superclass always creates a new char[] instance. For these two cases, we replace the created instance with a long-lived instance from a static field, saving 12-14 bytes per instance. @see o...
[ "Coalesce", "_scheme", "to", "existing", "instances", "where", "appropriate", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/url/LaxURI.java#L209-L219
train
iipc/webarchive-commons
src/main/java/org/archive/io/WriterPoolMember.java
WriterPoolMember.generateNewBasename
protected void generateNewBasename() { Properties localProps = new Properties(); localProps.setProperty("prefix", settings.getPrefix()); synchronized(this.getClass()) { // ensure that serialNo and timestamp are minted together (never inverted sort order) String paddedSer...
java
protected void generateNewBasename() { Properties localProps = new Properties(); localProps.setProperty("prefix", settings.getPrefix()); synchronized(this.getClass()) { // ensure that serialNo and timestamp are minted together (never inverted sort order) String paddedSer...
[ "protected", "void", "generateNewBasename", "(", ")", "{", "Properties", "localProps", "=", "new", "Properties", "(", ")", ";", "localProps", ".", "setProperty", "(", "\"prefix\"", ",", "settings", ".", "getPrefix", "(", ")", ")", ";", "synchronized", "(", "...
Generate a new basename by interpolating values in the configured template. Values come from local state, other configured values, and global system properties. The recommended default template will generate a unique basename under reasonable assumptions.
[ "Generate", "a", "new", "basename", "by", "interpolating", "values", "in", "the", "configured", "template", ".", "Values", "come", "from", "local", "state", "other", "configured", "values", "and", "global", "system", "properties", ".", "The", "recommended", "def...
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/WriterPoolMember.java#L270-L285
train
iipc/webarchive-commons
src/main/java/org/archive/io/WriterPoolMember.java
WriterPoolMember.getBaseFilename
protected String getBaseFilename() { String name = this.f.getName(); if (settings.getCompress() && name.endsWith(DOT_COMPRESSED_FILE_EXTENSION)) { return name.substring(0,name.length() - 3); } else if(settings.getCompress() && name.endsWith(DOT_COMPRESSED_FILE_EXTENSI...
java
protected String getBaseFilename() { String name = this.f.getName(); if (settings.getCompress() && name.endsWith(DOT_COMPRESSED_FILE_EXTENSION)) { return name.substring(0,name.length() - 3); } else if(settings.getCompress() && name.endsWith(DOT_COMPRESSED_FILE_EXTENSI...
[ "protected", "String", "getBaseFilename", "(", ")", "{", "String", "name", "=", "this", ".", "f", ".", "getName", "(", ")", ";", "if", "(", "settings", ".", "getCompress", "(", ")", "&&", "name", ".", "endsWith", "(", "DOT_COMPRESSED_FILE_EXTENSION", ")", ...
Get the file name @return the filename, as if uncompressed
[ "Get", "the", "file", "name" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/WriterPoolMember.java#L293-L305
train
iipc/webarchive-commons
src/main/java/org/archive/io/WriterPoolMember.java
WriterPoolMember.preWriteRecordTasks
protected void preWriteRecordTasks() throws IOException { if (this.out == null) { createFile(); } if (settings.getCompress()) { // Wrap stream in GZIP Writer. // The below construction immediately writes the GZIP 'default' // header out on the ...
java
protected void preWriteRecordTasks() throws IOException { if (this.out == null) { createFile(); } if (settings.getCompress()) { // Wrap stream in GZIP Writer. // The below construction immediately writes the GZIP 'default' // header out on the ...
[ "protected", "void", "preWriteRecordTasks", "(", ")", "throws", "IOException", "{", "if", "(", "this", ".", "out", "==", "null", ")", "{", "createFile", "(", ")", ";", "}", "if", "(", "settings", ".", "getCompress", "(", ")", ")", "{", "// Wrap stream in...
Post write tasks. Has side effects. Will open new file if we're at the upper bound. If we're writing compressed files, it will wrap output stream with a GZIP writer with side effect that GZIP header is written out on the stream. @exception IOException
[ "Post", "write", "tasks", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/WriterPoolMember.java#L329-L340
train
iipc/webarchive-commons
src/main/java/org/archive/io/WriterPoolMember.java
WriterPoolMember.postWriteRecordTasks
protected void postWriteRecordTasks() throws IOException { if (settings.getCompress()) { CompressedStream o = (CompressedStream)this.out; o.finish(); o.flush(); o.end(); this.out = o.getWrappedStream(); } }
java
protected void postWriteRecordTasks() throws IOException { if (settings.getCompress()) { CompressedStream o = (CompressedStream)this.out; o.finish(); o.flush(); o.end(); this.out = o.getWrappedStream(); } }
[ "protected", "void", "postWriteRecordTasks", "(", ")", "throws", "IOException", "{", "if", "(", "settings", ".", "getCompress", "(", ")", ")", "{", "CompressedStream", "o", "=", "(", "CompressedStream", ")", "this", ".", "out", ";", "o", ".", "finish", "("...
Post file write tasks. If compressed, finishes up compression and flushes stream so any subsequent checks get good reading. @exception IOException
[ "Post", "file", "write", "tasks", ".", "If", "compressed", "finishes", "up", "compression", "and", "flushes", "stream", "so", "any", "subsequent", "checks", "get", "good", "reading", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/WriterPoolMember.java#L349-L358
train
iipc/webarchive-commons
src/main/java/org/archive/format/gzip/zipnum/ZipNumCluster.java
ZipNumCluster.computeTotalLines
public long computeTotalLines() { long numLines = 0; try { numLines = this.getNumLines(summary.getRange("", "")); } catch (IOException e) { LOGGER.warning(e.toString()); return 0; } long adjustment = getTotalAdjustment(); numLines -= (getNumBlocks() - 1); numLines *= this.getCdxLinesPerB...
java
public long computeTotalLines() { long numLines = 0; try { numLines = this.getNumLines(summary.getRange("", "")); } catch (IOException e) { LOGGER.warning(e.toString()); return 0; } long adjustment = getTotalAdjustment(); numLines -= (getNumBlocks() - 1); numLines *= this.getCdxLinesPerB...
[ "public", "long", "computeTotalLines", "(", ")", "{", "long", "numLines", "=", "0", ";", "try", "{", "numLines", "=", "this", ".", "getNumLines", "(", "summary", ".", "getRange", "(", "\"\"", ",", "\"\"", ")", ")", ";", "}", "catch", "(", "IOException"...
Adjust from shorter blocks, if loaded
[ "Adjust", "from", "shorter", "blocks", "if", "loaded" ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/format/gzip/zipnum/ZipNumCluster.java#L493-L509
train
iipc/webarchive-commons
src/main/java/org/archive/format/text/charset/CharsetDetector.java
CharsetDetector.getCharsetFromMeta
protected String getCharsetFromMeta(byte buffer[],int len) throws IOException { String charsetName = null; // convert to UTF-8 String -- which hopefully will not mess up the // characters we're interested in... String sample = new String(buffer,0,len,DEFAULT_CHARSET); String metaContentType = findMetaContent...
java
protected String getCharsetFromMeta(byte buffer[],int len) throws IOException { String charsetName = null; // convert to UTF-8 String -- which hopefully will not mess up the // characters we're interested in... String sample = new String(buffer,0,len,DEFAULT_CHARSET); String metaContentType = findMetaContent...
[ "protected", "String", "getCharsetFromMeta", "(", "byte", "buffer", "[", "]", ",", "int", "len", ")", "throws", "IOException", "{", "String", "charsetName", "=", "null", ";", "// convert to UTF-8 String -- which hopefully will not mess up the", "// characters we're interest...
Attempt to find a META tag in the HTML that hints at the character set used to write the document. @param resource @return String character set found from META tags in the HTML @throws IOException
[ "Attempt", "to", "find", "a", "META", "tag", "in", "the", "HTML", "that", "hints", "at", "the", "character", "set", "used", "to", "write", "the", "document", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/format/text/charset/CharsetDetector.java#L168-L179
train
iipc/webarchive-commons
src/main/java/org/archive/format/text/charset/CharsetDetector.java
CharsetDetector.getCharsetFromBytes
protected String getCharsetFromBytes(byte buffer[], int len) throws IOException { String charsetName = null; UniversalDetector detector = new UniversalDetector(null); detector.handleData(buffer, 0, len); detector.dataEnd(); charsetName = detector.getDetectedCharset(); detector.reset(); if(is...
java
protected String getCharsetFromBytes(byte buffer[], int len) throws IOException { String charsetName = null; UniversalDetector detector = new UniversalDetector(null); detector.handleData(buffer, 0, len); detector.dataEnd(); charsetName = detector.getDetectedCharset(); detector.reset(); if(is...
[ "protected", "String", "getCharsetFromBytes", "(", "byte", "buffer", "[", "]", ",", "int", "len", ")", "throws", "IOException", "{", "String", "charsetName", "=", "null", ";", "UniversalDetector", "detector", "=", "new", "UniversalDetector", "(", "null", ")", ...
Attempts to figure out the character set of the document using the excellent juniversalchardet library. @param resource @return String character encoding found, or null if nothing looked good. @throws IOException
[ "Attempts", "to", "figure", "out", "the", "character", "set", "of", "the", "document", "using", "the", "excellent", "juniversalchardet", "library", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/format/text/charset/CharsetDetector.java#L231-L243
train
iipc/webarchive-commons
src/main/java/org/archive/io/ReplayInputStream.java
ReplayInputStream.readContentTo
public void readContentTo(OutputStream os, long maxSize) throws IOException { setToResponseBodyStart(); byte[] buf = new byte[4096]; int c = read(buf); long tot = 0; while (c != -1 && tot < maxSize) { os.write(buf,0,c); c = read(buf); tot += c;...
java
public void readContentTo(OutputStream os, long maxSize) throws IOException { setToResponseBodyStart(); byte[] buf = new byte[4096]; int c = read(buf); long tot = 0; while (c != -1 && tot < maxSize) { os.write(buf,0,c); c = read(buf); tot += c;...
[ "public", "void", "readContentTo", "(", "OutputStream", "os", ",", "long", "maxSize", ")", "throws", "IOException", "{", "setToResponseBodyStart", "(", ")", ";", "byte", "[", "]", "buf", "=", "new", "byte", "[", "4096", "]", ";", "int", "c", "=", "read",...
Convenience method to copy content out to target stream. @param os stream to write content to @param maxSize maximum count of bytes to copy @throws IOException
[ "Convenience", "method", "to", "copy", "content", "out", "to", "target", "stream", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/ReplayInputStream.java#L234-L244
train
iipc/webarchive-commons
src/main/java/org/archive/io/ReplayInputStream.java
ReplayInputStream.position
public void position(long p) throws IOException { if (p < 0) { throw new IOException("Negative seek offset."); } if (p > size) { throw new IOException("Desired position exceeds size."); } if (p < buffer.length) { // Only seek file if necessary ...
java
public void position(long p) throws IOException { if (p < 0) { throw new IOException("Negative seek offset."); } if (p > size) { throw new IOException("Desired position exceeds size."); } if (p < buffer.length) { // Only seek file if necessary ...
[ "public", "void", "position", "(", "long", "p", ")", "throws", "IOException", "{", "if", "(", "p", "<", "0", ")", "{", "throw", "new", "IOException", "(", "\"Negative seek offset.\"", ")", ";", "}", "if", "(", "p", ">", "size", ")", "{", "throw", "ne...
Reposition the stream. @param p the new position for this stream @throws IOException if an IO error occurs
[ "Reposition", "the", "stream", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/ReplayInputStream.java#L298-L314
train
iipc/webarchive-commons
src/main/java/org/archive/io/ArchiveRecord.java
ArchiveRecord.close
public void close() throws IOException { if (this.in != null) { skip(); this.in = null; if (this.digest != null) { this.digestStr = Base32.encode(this.digest.digest()); } } }
java
public void close() throws IOException { if (this.in != null) { skip(); this.in = null; if (this.digest != null) { this.digestStr = Base32.encode(this.digest.digest()); } } }
[ "public", "void", "close", "(", ")", "throws", "IOException", "{", "if", "(", "this", ".", "in", "!=", "null", ")", "{", "skip", "(", ")", ";", "this", ".", "in", "=", "null", ";", "if", "(", "this", ".", "digest", "!=", "null", ")", "{", "this...
Calling close on a record skips us past this record to the next record in the stream. It does not actually close the stream. The underlying steam is probably being used by the next arc record. @throws IOException
[ "Calling", "close", "on", "a", "record", "skips", "us", "past", "this", "record", "to", "the", "next", "record", "in", "the", "stream", "." ]
988bec707c27a01333becfc3bd502af4441ea1e1
https://github.com/iipc/webarchive-commons/blob/988bec707c27a01333becfc3bd502af4441ea1e1/src/main/java/org/archive/io/ArchiveRecord.java#L170-L178
train