/*-------------------------------------------------[ Retriving ]---------------------------------------------------
540290
public <X> X get(String namespaceURI, String localPart){
        return get(namespaceURI, localPart, (X)null);
    }
1240334
@SuppressLint({
      "LogNotTimber", //
      "StringFormatInTimber", //
      "ThrowableNotAtBeginning", //
      "BinaryOperationInTimber", //
      "TimberArgCount", //
      "TimberArgTypes", //
      "TimberTagLength", //
      "TimberExceptionLogging" //
  }) //
  @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // LogNotTimber
    Log.d("TAG", "msg");
    Log.d("TAG", "msg", new Exception());
    android.util.Log.d("TAG", "msg");
    android.util.Log.d("TAG", "msg", new Exception());

    // StringFormatInTimber
    Timber.w(String.format("%s", getString()));
    Timber.w(format("%s", getString()));

    // ThrowableNotAtBeginning
    Timber.d("%s", new Exception());

    // BinaryOperationInTimber
    String foo = "foo";
    String bar = "bar";
    Timber.d("foo" + "bar");
    Timber.d("foo" + bar);
    Timber.d(foo + "bar");
    Timber.d(foo + bar);

    // TimberArgCount
    Timber.d("%s %s", "arg0");
    Timber.d("%s", "arg0", "arg1");
    Timber.tag("tag").d("%s %s", "arg0");
    Timber.tag("tag").d("%s", "arg0", "arg1");

    // TimberArgTypes
    Timber.d("%d", "arg0");
    Timber.tag("tag").d("%d", "arg0");

    // TimberTagLength
    Timber.tag("abcdefghijklmnopqrstuvwx");
    Timber.tag("abcdefghijklmnopqrstuvw" + "x");

    // TimberExceptionLogging
    Timber.d(new Exception(), new Exception().getMessage());
    Timber.d(new Exception(), "");
    Timber.d(new Exception(), null);
    Timber.d(new Exception().getMessage());
  }
1027628
private void restoreFromSession(IExtendedRequest extRequest, HttpServletRequest req, String reqURL) {
		HttpSession postparamsession = req.getSession(false);
		if (postparamsession == null) {
			return;
		}
		String previousReq = (String) postparamsession.getAttribute(INITIAL_URL);
		if (previousReq != null && previousReq.equals(reqURL)) {
			try {
				if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
					Tr.debug(tc, "Found the session, restoring POST parameters.");
				}
				extRequest.setMethod("POST");
				Map paramValues = (Map) postparamsession.getAttribute(PARAM_VALUES);

				if (paramValues != null && !paramValues.isEmpty()) {
					if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
						Tr.debug(tc, "Restoring POST paramameters for URL : " + reqURL);
					}
					extRequest.setInputStreamData((HashMap) paramValues);
				}
			} catch (IOException exc) {
				if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
					Tr.debug(tc, "IOException restoring POST parameters onto a cookie: ", new Object[] { exc });
				}
			}
		} else if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
			Tr.debug(tc, "Parameters NOT restored. Original URL : " + previousReq + " req. URL : " + reqURL);
		}

		postparamsession.setAttribute(INITIAL_URL, null);
		postparamsession.setAttribute(PARAM_NAMES, null);
		postparamsession.setAttribute(PARAM_VALUES, null);
	}
900068
static public void main(String ... args) throws Exception {
        FileInputStream fin = new FileInputStream(args[0]);
        XMLReader<Sample> reader = new XMLReader<Sample>();
        
        for( Map<String,Object> map : reader.read(fin, Sample.class) ) {
            System.out.println("Next...");
            for( Map.Entry<String,Object> entry : map.entrySet() ) {
                System.out.println("\t" + entry.getKey() + " (" + (entry.getValue() != null ? entry.getValue().getClass().getName() : "") + "): " + entry.getValue());
            }
        }
    }
1320754
@Override
  public RequestLogs next() throws NoSuchElementException {
    Preconditions.checkNotNull(logIterator, "Reader was not initialized via beginSlice()");
    if (logIterator.hasNext()) {
      lastLog = logIterator.next();
      return lastLog;
    } else {
      log.fine("Shard completed: " + shardLogQuery.getStartTimeUsec() + "-"
          + shardLogQuery.getEndTimeUsec());
      throw new NoSuchElementException();
    }
  }
812563
private void consumeCRLF(ImapRequestLineReader request)
            throws ProtocolException {
        char next = request.nextChar();
        if (next != '\n') {
            consumeChar(request, '\r');
        }
        consumeChar(request, '\n');
    }
124585
@Override
	public void archive() {
		Log.info("Starting local archiving...");
		
		String fileName = FileHandlerUtil.generateAuditFileName(FileHandlerUtil.substractDate(new Date(),
				archiveDateDiff));
		String archiveFileName = FileHandlerUtil.generateAuditArchiveFileName(FileHandlerUtil.substractDate(new Date(),
				archiveDateDiff));

		String filePath = FileHandlerUtil.generateOutputFilePath(path, fileName);
		String archivePath = FileHandlerUtil.generateOutputFilePath(path, archiveFileName);

		if (FileHandlerUtil.isFileAlreadyExists(filePath)) {

			FileOutputStream fos = null;
			try {
				fos = new FileOutputStream(archivePath);
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			ZipOutputStream zos = new ZipOutputStream(fos);
			ZipEntry ze = new ZipEntry(fileName);
			try {
				zos.putNextEntry(ze);

				FileInputStream in = new FileInputStream(filePath);

				int len;
				while ((len = in.read(buffer)) > 0) {
					zos.write(buffer, 0, len);
				}

				in.close();
				zos.closeEntry();
				zos.close();
				System.out.println("Done");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
208115
protected void reBuffer()
    {
        resetBuffer();

        try
        {
            int read = buffer.length;
            if (bufferOffset + read > fileLength)
            {
                if (bufferOffset >= fileLength)
                    return;
                read = (int) (fileLength - bufferOffset);
            }

            channel.position(bufferOffset); // setting channel position

            int offset = 0;
            while (read > 0)
            {
                int n = super.read(buffer, offset, read);
                if (n < 0)
                    throw new IllegalStateException();
                read -= n;
                offset += n;
            }

            validBufferBytes = offset;
        }
        catch (IOException e)
        {
            throw new FSReadError(e, filePath);
        }
    }
265464
@Override
	public final Object retrieve(int handle) throws DataStoreException
    {
        if (SAFE_MODE) checkHandle(handle);
        
        // Compute total size
        int totalSize = computeSize(handle);
        
        // Retrieve all blocks
        byte[] data = new byte[totalSize];
        int offset = 0;
        int current = handle;
        while (current != -1)
        {
            int blockLen = allocatedSize[current];
            
            // Read block from map file
            readDataBlock(data,offset,blockLen,current);
            offset += blockLen;
            
            if ((flags[current] & FLAG_END_BLOCK) > 0)
                break;
            current = nextBlock[current];
        }
        if (current == -1)
            throw new DataStoreException("Can't find end block for "+handle);
        
        return data;
    }
32530
@Override
  public boolean write(SimpleDataEvent event) {
    LOG.info("Sending data to Apache Solr");
    HttpPost postMethod = new HttpPost(solrUrl);
    postMethod.setHeader("Content-type", "application/xml");
    StringEntity postEntity;
    try {
      postEntity = new StringEntity(XMLUtils.getSolrAddDocument(event.pairs()), "UTF-8");
      postMethod.setEntity(postEntity);
      return execute(postMethod);
    } catch (UnsupportedEncodingException uee) {
      LOG.error("Error sending event: " + uee);
      return false;
    }
  }
255314
int reallocate(int offset) {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.entry(this, tc, "reallocate", new Object[]{Integer.valueOf(offset)});

    byte[] oldContents = contents;
    int oldMessageOffset = messageOffset;
    contents = new byte[length];
    System.arraycopy(oldContents, messageOffset, contents, 0, length);
    tableOffset -= messageOffset;
    dataOffset -= messageOffset;
    messageOffset = 0;
    reallocated = true;
    reallocated(contents, -1);

    int result = offset - oldMessageOffset;

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) JmfTr.exit(this, tc, "reallocate", Integer.valueOf(result));
    return result;
  }
908369
@Override
    public String readSingle(String key) throws Exception {
        BoundStatement bStmt = readPstmt.bind();
        bStmt.setString("\"_id\"", key);
        bStmt.setConsistencyLevel(this.ReadConsistencyLevel);
        ResultSet rs = session.execute(bStmt);

        List<Row> result=rs.all();
        if (!result.isEmpty())
        {
            if (result.size() != 1) {
                throw new Exception("Num Cols returned not ok " + result.size());
            }
        }
        else {
            return CacheMiss;
        }

        return ResultOK;
    }
781244
@Override
	protected void submitRedoPut(final K key, final V value) {
		if (!useRedo) {
			return;
		}
		createRedoThread();
		final ByteBuffer buf = bufstack.pop();
		buf.put((byte) 0x0A); // PUT HEADER
		key.serialize(buf);
		value.serialize(buf);
		buf.put((byte) 0x0A); // PUT FOOTER
		buf.flip();
		if (useRedoThread) {
			try {
				redoQueue.put(buf);
			} catch (InterruptedException e) {
				log.error("InterruptedException in submitRedoPut(key, value)", e);
			}
		} else {
			redoStore.write(buf);
			bufstack.push(buf);
		}
	}
194614
public void doGet(HttpServletRequest request, HttpServletResponse response) 
        throws ServletException, IOException
    {
        response.setContentType("text/html");
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Cache-Control", "no-cache,no-store");

        String url=request.getParameter("URL");
        if (url!=null && url.length()>0)
        {
            response.sendRedirect(url);
        }
        else
        {
            PrintWriter pout = response.getWriter();
            Page page=null;
            
            try{
                page = new Page();
                page.title("SendRedirect Servlet");     
                
                page.add(new Heading(1,"SendRedirect Servlet"));
                
                page.add(new Heading(1,"Form to generate Dump content"));
                TableForm tf = new TableForm
                    (response.encodeURL(URI.addPaths(request.getContextPath(),
                                                     request.getServletPath())+
                                        "/action"));
                tf.method("GET");
                tf.addTextField("URL","URL",40,request.getContextPath()+"/dump");
                tf.addButton("Redirect","Redirect");
                page.add(tf);
                page.write(pout);
                pout.close();
            }
            catch (Exception e)
            {
                log.warn(LogSupport.EXCEPTION,e);
            }
        }
    }
666504
private void saveToSession(HttpServletRequest req, String reqURL, Map params) {
		HttpSession postparamsession = req.getSession(true);
		if (postparamsession != null && params != null && !params.isEmpty()) {
			postparamsession.setAttribute(INITIAL_URL, reqURL);
			postparamsession.setAttribute(PARAM_NAMES, null);
			postparamsession.setAttribute(PARAM_VALUES, params);
			if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
				Tr.debug(tc, "URL saved: " + reqURL.toString());
			}
		}
	}
968826
private static <T> void _logResult(T result, int level, int indentSize, StringBuilder info) {
        if(result instanceof Map) {
            level += 1;
            int finalLevel = level;
            ((Map)result).forEach((k, v) -> {
                info.append("\n");
                info.append(getTabBasedOnLevel(finalLevel, indentSize))
                        .append(k.toString())
                        .append(":");
                _logResult(v, finalLevel, indentSize, info);
            });
        } else if(result instanceof List) {
            int finalLevel = level;
            ((List)result).forEach(element -> _logResult(element, finalLevel, indentSize, info));
        } else if(result instanceof String) {
            info.append(" ").append(result);
        } else if(result != null) {
            try {
                logger.warn(getTabBasedOnLevel(level, indentSize) + "{}", result);
            } catch (Exception e) {
                logger.error("Cannot handle this type: {}", result.getClass().getTypeName());
            }
        }
    }
878886
@SuppressWarnings("unchecked")
  @Override
  public REC previous() {
    checkDirection(false);

    if (currentRecord != null)
      try {
        // RETURN LAST LOADED RECORD
        return (REC) currentRecord;
      } finally {
        currentRecord = null;
      }

    ORecordInternal<?> record = getRecord();

    // MOVE BACKWARD IN THE CURRENT CLUSTER
    while (hasPrevious()) {
      if (currentRecord != null)
        try {
          // RETURN LAST LOADED RECORD
          return (REC) currentRecord;
        } finally {
          currentRecord = null;
        }

      if (record == null)
        record = readCurrentRecord(null, -1);

      if (record != null)
        // FOUND
        if (include(record))
          return (REC) record;
    }

    record = getTransactionEntry();
    if (record != null)
      return (REC) record;

    throw new NoSuchElementException("Direction: backward, last position was: " + current + ", range: " + beginRange + "-"
        + endRange);
  }