| 1 | /* |
| 2 | * $Id: VisitClassName.java,v 1.3 2004/05/25 21:04:38 hastings Exp $ |
| 3 | * |
| 4 | * (c) Copyright, Moebius Solutions, Inc., 2004 |
| 5 | * |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This material may be reproduced by or for the U. S. Government |
| 9 | * pursuant to the copyright license under the clause at |
| 10 | * DFARS 252.227-7014 (OCT 2001). |
| 11 | */ |
| 12 | |
| 13 | package com.moesol.generator.core; |
| 14 | |
| 15 | import com.moesol.generator.visitor.*; |
| 16 | |
| 17 | /** |
| 18 | * Breaks up foo.bar.ClassName and visits |
| 19 | * visitPartName("foo"); |
| 20 | * visitPartName("bar"); |
| 21 | * visitClassName("ClassName"); |
| 22 | */ |
| 23 | public class VisitClassName { |
| 24 | public static void visit(Class c, ClassNameVisitor v) { |
| 25 | String full_name = c.getName(); |
| 26 | StringBuffer current = new StringBuffer(); |
| 27 | for (int i = 0; i < full_name.length(); i++) { |
| 28 | if ('.' == full_name.charAt(i)) { |
| 29 | v.visitPartName(current.toString()); |
| 30 | current.setLength(0); |
| 31 | } else { |
| 32 | current.append(full_name.charAt(i)); |
| 33 | } |
| 34 | } |
| 35 | v.visitClassName(current.toString()); |
| 36 | } |
| 37 | } |