diff src/org/tmatesoft/hg/core/SessionContext.java @ 571:e4ee4bf4c7d0

Let session context control creation of Path instances
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 11 Apr 2013 16:27:06 +0200
parents b3c16d1aede0
children fba85bc1dfb8
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/core/SessionContext.java	Thu Apr 11 16:07:17 2013 +0200
+++ b/src/org/tmatesoft/hg/core/SessionContext.java	Thu Apr 11 16:27:06 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2012 TMate Software Ltd
+ * Copyright (c) 2011-2013 TMate Software Ltd
  *  
  * 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
@@ -17,6 +17,7 @@
 package org.tmatesoft.hg.core;
 
 import org.tmatesoft.hg.util.LogFacility;
+import org.tmatesoft.hg.util.Path;
 
 /**
  * Access to objects that might need to be shared between various distinct operations ran during the same working session 
@@ -47,6 +48,25 @@
 	// e.g. when there's standalone Caches and WritableSessionProperties objects
 
 	/**
+	 * Provide a factory to create {@link Path} objects.
+	 * 
+	 * Occasionally, there's a need to construct a {@link Path} object from a string/byte data 
+	 * kept in mercurial control files. Generally, default implementation (with {@link Path#create(CharSequence)} 
+	 * is enough, however, if there's a need to control number of string objects in memory (i.e. prevent duplicates),
+	 * default implementation might need to be replaced with more sophisticated (e.g. using weak references or
+	 * just a huge hash set).
+	 * 
+	 * @return factory to construct Path objects, never <code>null</code>
+	 */
+	public Path.Source getPathFactory() {
+		return new Path.Source() {
+			public Path path(CharSequence p) {
+				return Path.create(p);
+			}
+		};
+	}
+
+	/**
 	 * Providers of the context may implement
 	 */
 	public interface Source {