--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.services.stream.BasicGetLogHeader\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.services.stream;\r
+\r
+import org.apache.derby.iapi.services.stream.PrintWriterGetHeader;\r
+import org.apache.derby.iapi.util.CheapDateFormatter;\r
+\r
+/**\r
+ * Get a header to prepend to a line of output. *\r
+ * A HeaderPrintWriter requires an object which implements\r
+ * this interface to construct line headers.\r
+ *\r
+ * @see org.apache.derby.iapi.services.stream.HeaderPrintWriter\r
+ */\r
+\r
+class BasicGetLogHeader implements PrintWriterGetHeader\r
+{\r
+ \r
+ private boolean doThreadId;\r
+ private boolean doTimeStamp;\r
+ private String tag;\r
+\r
+ /* \r
+ * STUB: This should take a header template. Check if\r
+ * the error message facility provides something.\r
+ * \r
+ * This should be localizable. How?\r
+ */\r
+ /**\r
+ * Constructor for a BasicGetLogHeader object.\r
+ * <p>\r
+ * @param doThreadId true means include the calling thread's\r
+ * id in the header.\r
+ * @param doTimeStamp true means include the current time in \r
+ * the header.\r
+ * @param tag A string to prefix the header. null\r
+ * means don't prefix the header with\r
+ * a string.\r
+ */\r
+ BasicGetLogHeader(boolean doThreadId,\r
+ boolean doTimeStamp,\r
+ String tag){\r
+ this.doThreadId = doThreadId;\r
+ this.doTimeStamp = doTimeStamp;\r
+ this.tag = tag;\r
+ } \r
+ \r
+ public String getHeader()\r
+ {\r
+ StringBuffer header = new StringBuffer(48);\r
+\r
+ if (tag != null) {\r
+ header.append(tag);\r
+ header.append(' ');\r
+ }\r
+\r
+ if (doTimeStamp) {\r
+ long currentTime = System.currentTimeMillis();\r
+\r
+ header.append(CheapDateFormatter.formatDate(currentTime));\r
+ header.append(' ');\r
+\r
+ }\r
+ if (doThreadId) {\r
+ header.append(Thread.currentThread().toString());\r
+ header.append(' ');\r
+ }\r
+\r
+ return header.toString();\r
+ }\r
+}\r
+ \r