001 // Copyright 2004, 2005 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 015 package org.apache.hivemind.schema.rules; 016 017 import org.apache.hivemind.Element; 018 import org.apache.hivemind.schema.SchemaProcessor; 019 020 /** 021 * Used to set a property of the child object to its parent object. The child object is the top 022 * object on the {@link org.apache.hivemind.schema.SchemaProcessor} stack, the parent object is the 023 * next object in. Created from the <code><set-parent></code> element. 024 * 025 * @author Howard Lewis Ship 026 */ 027 public class SetParentRule extends BaseRule 028 { 029 private String _propertyName; 030 031 /** 032 * @since 1.1 033 */ 034 public String getPropertyName() 035 { 036 return _propertyName; 037 } 038 039 public void setPropertyName(String string) 040 { 041 _propertyName = string; 042 } 043 044 public void begin(SchemaProcessor processor, Element element) 045 { 046 Object child = processor.peek(); 047 Object parent = processor.peek(1); 048 049 RuleUtils.setProperty(processor, element, _propertyName, child, parent); 050 } 051 052 }