001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache license, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the license for the specific language governing permissions and 015 * limitations under the license. 016 */ 017 package org.apache.logging.log4j.core.impl; 018 019 import java.io.Serializable; 020 021 /** 022 * Package data for a StackTraceElement. 023 */ 024 public class StackTracePackageElement implements Serializable { 025 026 private static final long serialVersionUID = -2171069569241280505L; 027 028 private final String location; 029 030 private final String version; 031 032 private final boolean isExact; 033 034 /** 035 * Constructor that takes the location, version, and exact match flag. 036 * @param location The location of the Class. 037 * @param version The version of the component. 038 * @param exact if true this is an exact package element. 039 */ 040 public StackTracePackageElement(final String location, final String version, final boolean exact) { 041 this.location = location; 042 this.version = version; 043 this.isExact = exact; 044 } 045 046 /** 047 * Returns the location of the element. 048 * @return The location of the element. 049 */ 050 public String getLocation() { 051 return location; 052 } 053 054 /** 055 * Returns the version of the element. 056 * @return the version of the element. 057 */ 058 public String getVersion() { 059 return version; 060 } 061 062 /** 063 * Returns the indicator of whether this is an exact match. 064 * @return true if the location was determined exactly. 065 */ 066 public boolean isExact() { 067 return isExact; 068 } 069 070 @Override 071 public String toString() { 072 final String exact = isExact ? "" : "~"; 073 return exact + "[" + location + ":" + version + "]"; 074 } 075 }