Package org.jwat.common

Examples of org.jwat.common.HeaderLine


                record.close();

                Assert.assertNull(record.getHeader(null));
                Assert.assertNull(record.getHeader(""));

                HeaderLine header1 = record.getHeader("header1");
                HeaderLine header2 = record.getHeader("HEADER2");

                Assert.assertNotNull(header1);
                Assert.assertNotNull(header2);

                Assert.assertEquals("hello", header1.value);
View Full Code Here


            // Test getHeader(s)
            List<HeaderLine> headerLines = header.getHeaderList();
            // debug
            //System.out.println(headerLines.size());
            Assert.assertEquals(values.length, headerLines.size());
            HeaderLine headerLine;
            for (int j=0; j<headerLines.size(); ++j) {
                headerLine = headerLines.get(j);
                Assert.assertEquals(fieldName, headerLine.name);
                Assert.assertEquals((String)values[j][0], headerLine.value);
            }
View Full Code Here

        boolean bInvalidDataBeforeVersion = false;
        boolean bEmptyLinesBeforeVersion = false;
        boolean bSeekRecord = true;
        while (bSeekRecord) {
            startOffset = in.getConsumed();
            HeaderLine recordLine = HeaderLine.readLine(in);
            if (recordLine != null) {
                if (recordLine.line.length() > 0) {
                    String[] fields = recordLine.line.split(" ", -1);
                    if (fields.length == ArcConstants.VERSION_1_BLOCK_NUMBER_FIELDS
                            || fields.length == ArcConstants.VERSION_2_BLOCK_NUMBER_FIELDS) {
View Full Code Here

    protected boolean parseVersion(ByteCountingPushBackInputStream in) throws IOException {
        bMagicIdentified = false;
        bVersionParsed = false;
        boolean bInvalidDataBeforeVersion = false;
        boolean bEmptyLinesBeforeVersion = false;
        HeaderLine line;
        String tmpStr;
        boolean bSeekMagic = true;
        // Loop until when have found something that looks like a version line.
        while (bSeekMagic) {
            // This is only relevant for uncompressed sequentially read records
View Full Code Here

     * encountered.
     * @param in header input stream
     * @throws IOException if an error occurs while reading the WARC header
     */
    protected void parseHeaders(ByteCountingPushBackInputStream in) throws IOException {
        HeaderLine headerLine;
        boolean bLoop = true;
        while (bLoop) {
            headerLine = reader.headerLineReader.readLine(in);
            if (!reader.headerLineReader.bEof) {
                headerBytesOut.write(headerLine.raw);
View Full Code Here

            } else {
                // Duplicate field.
                addErrorDiagnosis(DiagnosisType.DUPLICATE, "'" + fieldName + "' header", fieldValue);
            }
        }
        HeaderLine tmpLine = headerMap.get(fieldName.toLowerCase());
        if (tmpLine == null) {
            headerMap.put(fieldName.toLowerCase(), headerLine);
        } else {
            tmpLine.lines.add(headerLine);
        }
View Full Code Here

     * @param fieldName name of field to add
     * @param fieldValue field value string
     * @return <code>HeaderLine</code> object corresponding to what would have been read
     */
    public HeaderLine addHeader(String fieldName, String fieldValue) {
        HeaderLine headerLine = new HeaderLine();
        headerLine.name = fieldName;
        headerLine.value = fieldValue;
        addHeader(headerLine);
        return headerLine;
    }
View Full Code Here

                        WarcConstants.FDT_IDX_STRINGS[WarcConstants.FN_IDX_DT[fn_idx]],
                        WarcConstants.FDT_IDX_STRINGS[dt]);
                // Consider throwing exception at some point.
            }
        }
        HeaderLine headerLine = new HeaderLine();
        headerLine.name = fieldName;
        headerLine.value = fieldValueStr;
        HeaderLine tmpLine = headerMap.get(fieldName.toLowerCase());
        if (tmpLine == null) {
            headerMap.put(fieldName.toLowerCase(), headerLine);
        } else {
            tmpLine.lines.add(headerLine);
        }
View Full Code Here

    } else {
      r.setInputStream(r.payloadStream);
          r.headers = new Hashtable<String,String>();
      if (httpHeader != null) {
        Iterator<HeaderLine> headerLines = httpHeader.getHeaderList().iterator();
        HeaderLine headerLine;
        while (headerLines.hasNext()) {
          headerLine = headerLines.next();
          r.headers.put(headerLine.name.toLowerCase(), headerLine.value);
        }
      }
View Full Code Here

TOP

Related Classes of org.jwat.common.HeaderLine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.