1 // ================================================================================================= 2 // ADOBE SYSTEMS INCORPORATED 3 // Copyright 2006 Adobe Systems Incorporated 4 // All Rights Reserved 5 // 6 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms 7 // of the Adobe license agreement accompanying it. 8 // ================================================================================================= 9 10 package com.adobe.xmp.impl.xpath; 11 12 13 /** 14 * A segment of a parsed <code>XMPPath</code>. 15 * 16 * @since 23.06.2006 17 */ 18 public class XMPPathSegment 19 { 20 /** name of the path segment */ 21 private String name; 22 /** kind of the path segment */ 23 private int kind; 24 /** flag if segment is an alias */ 25 private boolean alias; 26 /** alias form if applicable */ 27 private int aliasForm; 28 29 30 /** 31 * Constructor with initial values. 32 * 33 * @param name the name of the segment 34 */ 35 public XMPPathSegment(String name) 36 { 37 this.name = name; 38 } 39 40 41 /** 42 * Constructor with initial values. 43 * 44 * @param name the name of the segment 45 * @param kind the kind of the segment 46 */ 47 public XMPPathSegment(String name, int kind) 48 { 49 this.name = name; 50 this.kind = kind; 51 } 52 53 54 /** 55 * @return Returns the kind. 56 */ 57 public int getKind() 58 { 59 return kind; 60 } 61 62 63 /** 64 * @param kind The kind to set. 65 */ 66 public void setKind(int kind) 67 { 68 this.kind = kind; 69 } 70 71 72 /** 73 * @return Returns the name. 74 */ 75 public String getName() 76 { 77 return name; 78 } 79 80 81 /** 82 * @param name The name to set. 83 */ 84 public void setName(String name) 85 { 86 this.name = name; 87 } 88 89 90 /** 91 * @param alias the flag to set 92 */ 93 public void setAlias(boolean alias) 94 { 95 this.alias = alias; 96 } 97 98 99 /** 100 * @return Returns the alias. 101 */ 102 public boolean isAlias() 103 { 104 return alias; 105 } 106 107 108 /** 109 * @return Returns the aliasForm if this segment has been created by an alias. 110 */ 111 public int getAliasForm() 112 { 113 return aliasForm; 114 } 115 116 117 /** 118 * @param aliasForm the aliasForm to set 119 */ 120 public void setAliasForm(int aliasForm) 121 { 122 this.aliasForm = aliasForm; 123 } 124 125 126 /** 127 * @see Object#toString() 128 */ 129 public String toString() 130 { 131 switch (kind) 132 { 133 case XMPPath.STRUCT_FIELD_STEP: 134 case XMPPath.ARRAY_INDEX_STEP: 135 case XMPPath.QUALIFIER_STEP: 136 case XMPPath.ARRAY_LAST_STEP: 137 return name; 138 case XMPPath.QUAL_SELECTOR_STEP: 139 case XMPPath.FIELD_SELECTOR_STEP: 140 return name; 141 142 default: 143 // no defined step 144 return name; 145 } 146 } 147 } 148