ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/jasper/compiler/ServletWriter.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/jasper/compiler/ServletWriter.java
Status
scanned
Type
file
Name
ServletWriter.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
4190 (4.1 KB)
MD5
d724f70612975f87758ad30811cbe145
SHA1
64e0b9471c7195b1432feb4a3d989052c15e001f
SHA256
58a14b3ba15992d3fb8914ff1fa1561452f48428deedf3e4e3a3679e11d89729
SHA512

      
    
SHA1_git
d490dade1925399bc908b599ff2941476f81f5ca
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ServletWriter.java | 4.1 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.jasper.compiler; import java.io.PrintWriter; /** * This is what is used to generate servlets. */ public class ServletWriter implements AutoCloseable { private static final int TAB_WIDTH = 2; private static final String SPACES = " "; /** * Current indent level. */ private int indent = 0; private int virtual_indent = 0; /** * The sink writer. */ private final PrintWriter writer; /** * Servlet line numbers start from 1. */ private int javaLine = 1; public ServletWriter(PrintWriter writer) { this.writer = writer; } @Override public void close() { writer.close(); } // -------------------- Access information -------------------- public int getJavaLine() { return javaLine; } // -------------------- Formatting -------------------- public void pushIndent() { virtual_indent += TAB_WIDTH; if (virtual_indent >= 0 && virtual_indent <= SPACES.length()) { indent = virtual_indent; } } public void popIndent() { virtual_indent -= TAB_WIDTH; if (virtual_indent >= 0 && virtual_indent <= SPACES.length()) { indent = virtual_indent; } } /** * Prints the given string followed by ' ' * * @param s The string */ public void println(String s) { javaLine++; writer.println(s); } /** * Prints a ' ' */ public void println() { javaLine++; writer.println(""); } /** * Prints the current indentation */ public void printin() { writer.print(SPACES.substring(0, indent)); } /** * Prints the current indentation, followed by the given string * * @param s The string */ public void printin(String s) { writer.print(SPACES.substring(0, indent)); writer.print(s); } /** * Prints the current indentation, and then the string, and a ' '. * * @param s The string */ public void printil(String s) { javaLine++; writer.print(SPACES.substring(0, indent)); writer.println(s); } /** * Prints the given char. Use println() to print a ' '. * * @param c The char */ public void print(char c) { writer.print(c); } /** * Prints the given int. * * @param i The int */ public void print(int i) { writer.print(i); } /** * Prints the given string. The string must not contain any ' ', otherwise the line count will be off. * * @param s The string */ public void print(String s) { writer.print(s); } /** * Prints the given string. If the string spans multiple lines, the line count will be adjusted accordingly. * * @param s The string */ public void printMultiLn(String s) { int index = 0; // look for hidden newlines inside strings while ((index = s.indexOf(' ', index)) > -1) { javaLine++; index++; } writer.print(s); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
27.05
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9