org.apache.commons.imaging.util.Debug Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-imaging Show documentation
Show all versions of commons-imaging Show documentation
Apache Commons Imaging (previously Sanselan) is a pure-Java image library.
The newest version!
/*
* 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.commons.imaging.util;
import java.awt.color.ICC_Profile;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
public final class Debug {
private static final boolean DEBUG = false;
// public static String newline = System.getProperty("line.separator");
private static final String NEWLINE = "\r\n";
private static long counter;
public static void debug(final String message) {
if (DEBUG) {
System.out.println(message);
}
}
public static void debug() {
if (DEBUG) {
System.out.print(NEWLINE);
}
}
private static String getDebug(final String message, final int[] v) {
final StringBuilder result = new StringBuilder();
if (v == null) {
result.append(message + " (" + null + ")" + NEWLINE);
} else {
result.append(message + " (" + v.length + ")" + NEWLINE);
for (final int element : v) {
result.append("\t" + element + NEWLINE);
}
result.append(NEWLINE);
}
return result.toString();
}
private static String getDebug(final String message, final byte[] v) {
final int max = 250;
return getDebug(message, v, max);
}
private static String getDebug(final String message, final byte[] v, final int max) {
final StringBuilder result = new StringBuilder();
if (v == null) {
result.append(message + " (" + null + ")" + NEWLINE);
} else {
result.append(message + " (" + v.length + ")" + NEWLINE);
for (int i = 0; i < max && i < v.length; i++) {
final int b = 0xff & v[i];
char c;
if (b == 0 || b == 10 || b == 11 || b == 13) {
c = ' ';
} else {
c = (char) b;
}
result.append("\t" + i + ": " + b + " (" + c + ", 0x"
+ Integer.toHexString(b) + ")" + NEWLINE);
}
if (v.length > max) {
result.append("\t..." + NEWLINE);
}
result.append(NEWLINE);
}
return result.toString();
}
private static String getDebug(final String message, final char[] v) {
final StringBuilder result = new StringBuilder();
if (v == null) {
result.append(message + " (" + null + ")" + NEWLINE);
} else {
result.append(message + " (" + v.length + ")" + NEWLINE);
for (final char element : v) {
result.append("\t" + element + " (" + (0xff & element) + ")" + NEWLINE);
}
result.append(NEWLINE);
}
return result.toString();
}
private static void debug(final String message, final Map, ?> map) {
debug(getDebug(message, map));
}
private static String getDebug(final String message, final Map, ?> map) {
final StringBuilder result = new StringBuilder();
if (map == null) {
return message + " map: " + null;
}
final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy