// Path: src/main/java/net/pterodactylus/wotns/freenet/wot/Identity.java
// public interface Identity {
// 
// 	/**
// 	 * Returns the ID of the identity.
// 	 *
// 	 * @return The ID of the identity
// 	 */
// 	public String getId();
// 
// 	/**
// 	 * Returns the nickname of the identity.
// 	 *
// 	 * @return The nickname of the identity
// 	 */
// 	public String getNickname();
// 
// 	/**
// 	 * Returns the request URI of the identity.
// 	 *
// 	 * @return The request URI of the identity
// 	 */
// 	public String getRequestUri();
// 
// 	/**
// 	 * Returns all contexts of this identity.
// 	 *
// 	 * @return All contexts of this identity
// 	 */
// 	public Set<String> getContexts();
// 
// 	/**
// 	 * Returns whether this identity has the given context.
// 	 *
// 	 * @param context
// 	 *            The context to check for
// 	 * @return {@code true} if this identity has the given context,
// 	 *         {@code false} otherwise
// 	 */
// 	public boolean hasContext(String context);
// 
// 	/**
// 	 * Returns all properties of this identity.
// 	 *
// 	 * @return All properties of this identity
// 	 */
// 	public Map<String, String> getProperties();
// 
// 	/**
// 	 * Returns the value of the property with the given name.
// 	 *
// 	 * @param name
// 	 *            The name of the property
// 	 * @return The value of the property
// 	 */
// 	public String getProperty(String name);
// 
// 	/**
// 	 * Retrieves the trust that this identity receives from the given own
// 	 * identity. If this identity is not in the own identity’s trust tree, a
// 	 * {@link Trust} is returned that has all its elements set to {@code null}.
// 	 * If the trust can not be retrieved, {@code null} is returned.
// 	 *
// 	 * @param ownIdentity
// 	 *            The own identity to get the trust for
// 	 * @return The trust assigned to this identity, or {@code null} if the trust
// 	 *         could not be retrieved
// 	 */
// 	public Trust getTrust(OwnIdentity ownIdentity);
// 
// }
// 
// Path: src/main/java/net/pterodactylus/wotns/main/IdentityTargets.java
// public class IdentityTargets implements Iterable<Entry<String, String>> {
// 
// 	/** The identity being scanned. */
// 	private final Identity identity;
// 
// 	/** The located targets. */
// 	private final Map<String, String> targets = new HashMap<String, String>();
// 
// 	/**
// 	 * Creates a new target scanner for the given identity.
// 	 *
// 	 * @param identity
// 	 *            The identity to scan for targets
// 	 */
// 	public IdentityTargets(Identity identity) {
// 		this.identity = identity;
// 	}
// 
// 	//
// 	// ACCESSORS
// 	//
// 
// 	/**
// 	 * Returns the targets of the identity.
// 	 *
// 	 * @return The targets defined in the identity
// 	 */
// 	public Map<String, String> getTargets() {
// 		scanForTargets();
// 		return Collections.unmodifiableMap(targets);
// 	}
// 
// 	/**
// 	 * Returns the target with the given name.
// 	 *
// 	 * @param name
// 	 *            The name of the target
// 	 * @return The target
// 	 */
// 	public String getTarget(String name) {
// 		scanForTargets();
// 		return targets.get(name);
// 	}
// 
// 	//
// 	// PRIVATE METHODS
// 	//
// 
// 	/**
// 	 * Re-scans the identity for targets.
// 	 */
// 	private void scanForTargets() {
// 		synchronized (targets) {
// 			targets.clear();
// 			for (Entry<String, String> property : identity.getProperties().entrySet()) {
// 				if (property.getKey().startsWith("tns.")) {
// 					targets.put(property.getKey().substring(4), property.getValue());
// 				}
// 			}
// 		}
// 	}
// 
// 	//
// 	// ITERABLE METHODS
// 	//
// 
// 	/**
// 	 * {@inheritDoc}
// 	 */
// 	@Override
// 	public Iterator<Entry<String, String>> iterator() {
// 		synchronized (targets) {
// 			scanForTargets();
// 			return new HashMap<String, String>(targets).entrySet().iterator();
// 		}
// 	}
// 
// }


import net.pterodactylus.util.template.Accessor;
import net.pterodactylus.util.template.ReflectionAccessor;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.wotns.freenet.wot.Identity;
import net.pterodactylus.wotns.main.IdentityTargets;
/*
 * WoTNS - IdentityAccessor.java - Copyright © 2011 David Roden
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package net.pterodactylus.wotns.template;


/**
 * {@link Accessor} implementation that can expose {@link IdentityTargets} for
 * an {@link Identity}.
 *
 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
 */
public class IdentityAccessor extends ReflectionAccessor {

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Object get(TemplateContext templateContext, Object object, String member) {
// Path: src/main/java/net/pterodactylus/wotns/freenet/wot/Identity.java
// public interface Identity {
// 
// 	/**
// 	 * Returns the ID of the identity.
// 	 *
// 	 * @return The ID of the identity
// 	 */
// 	public String getId();
// 
// 	/**
// 	 * Returns the nickname of the identity.
// 	 *
// 	 * @return The nickname of the identity
// 	 */
// 	public String getNickname();
// 
// 	/**
// 	 * Returns the request URI of the identity.
// 	 *
// 	 * @return The request URI of the identity
// 	 */
// 	public String getRequestUri();
// 
// 	/**
// 	 * Returns all contexts of this identity.
// 	 *
// 	 * @return All contexts of this identity
// 	 */
// 	public Set<String> getContexts();
// 
// 	/**
// 	 * Returns whether this identity has the given context.
// 	 *
// 	 * @param context
// 	 *            The context to check for
// 	 * @return {@code true} if this identity has the given context,
// 	 *         {@code false} otherwise
// 	 */
// 	public boolean hasContext(String context);
// 
// 	/**
// 	 * Returns all properties of this identity.
// 	 *
// 	 * @return All properties of this identity
// 	 */
// 	public Map<String, String> getProperties();
// 
// 	/**
// 	 * Returns the value of the property with the given name.
// 	 *
// 	 * @param name
// 	 *            The name of the property
// 	 * @return The value of the property
// 	 */
// 	public String getProperty(String name);
// 
// 	/**
// 	 * Retrieves the trust that this identity receives from the given own
// 	 * identity. If this identity is not in the own identity’s trust tree, a
// 	 * {@link Trust} is returned that has all its elements set to {@code null}.
// 	 * If the trust can not be retrieved, {@code null} is returned.
// 	 *
// 	 * @param ownIdentity
// 	 *            The own identity to get the trust for
// 	 * @return The trust assigned to this identity, or {@code null} if the trust
// 	 *         could not be retrieved
// 	 */
// 	public Trust getTrust(OwnIdentity ownIdentity);
// 
// }
// 
// Path: src/main/java/net/pterodactylus/wotns/main/IdentityTargets.java
// public class IdentityTargets implements Iterable<Entry<String, String>> {
// 
// 	/** The identity being scanned. */
// 	private final Identity identity;
// 
// 	/** The located targets. */
// 	private final Map<String, String> targets = new HashMap<String, String>();
// 
// 	/**
// 	 * Creates a new target scanner for the given identity.
// 	 *
// 	 * @param identity
// 	 *            The identity to scan for targets
// 	 */
// 	public IdentityTargets(Identity identity) {
// 		this.identity = identity;
// 	}
// 
// 	//
// 	// ACCESSORS
// 	//
// 
// 	/**
// 	 * Returns the targets of the identity.
// 	 *
// 	 * @return The targets defined in the identity
// 	 */
// 	public Map<String, String> getTargets() {
// 		scanForTargets();
// 		return Collections.unmodifiableMap(targets);
// 	}
// 
// 	/**
// 	 * Returns the target with the given name.
// 	 *
// 	 * @param name
// 	 *            The name of the target
// 	 * @return The target
// 	 */
// 	public String getTarget(String name) {
// 		scanForTargets();
// 		return targets.get(name);
// 	}
// 
// 	//
// 	// PRIVATE METHODS
// 	//
// 
// 	/**
// 	 * Re-scans the identity for targets.
// 	 */
// 	private void scanForTargets() {
// 		synchronized (targets) {
// 			targets.clear();
// 			for (Entry<String, String> property : identity.getProperties().entrySet()) {
// 				if (property.getKey().startsWith("tns.")) {
// 					targets.put(property.getKey().substring(4), property.getValue());
// 				}
// 			}
// 		}
// 	}
// 
// 	//
// 	// ITERABLE METHODS
// 	//
// 
// 	/**
// 	 * {@inheritDoc}
// 	 */
// 	@Override
// 	public Iterator<Entry<String, String>> iterator() {
// 		synchronized (targets) {
// 			scanForTargets();
// 			return new HashMap<String, String>(targets).entrySet().iterator();
// 		}
// 	}
// 
// }


// Path: src/main/java/net/pterodactylus/wotns/template/IdentityAccessor.java
import net.pterodactylus.util.template.Accessor;
import net.pterodactylus.util.template.ReflectionAccessor;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.wotns.freenet.wot.Identity;
import net.pterodactylus.wotns.main.IdentityTargets;

/*
 * WoTNS - IdentityAccessor.java - Copyright © 2011 David Roden
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package net.pterodactylus.wotns.template;


/**
 * {@link Accessor} implementation that can expose {@link IdentityTargets} for
 * an {@link Identity}.
 *
 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
 */
public class IdentityAccessor extends ReflectionAccessor {

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Object get(TemplateContext templateContext, Object object, String member) {
		Identity identity = (Identity) object;