Data Handler¸¦ °³¹ßÇϱâ À§ÇØ, DataHandler Ŭ·¡½ºÀÇ ´ÙÀ½ ¸Þ¼Òµå¸¦ ±¸ÇöÇÕ´Ï´Ù.
Custom Data HandlerÀÇ ¸Þ¼Òµå´Â Data Handler ±âº» Ŭ·¡½º È®Àå¿¡¼ ÀÛ¼ºÇÑ DataHandler Ŭ·¡½ºÀÇ Java ¼Ò½º ÆÄÀÏ·Î ÁøÇàÇÕ´Ï´Ù.
data-handler ±âº» Ŭ·¡½ºÀÎ DataHandler´Â Custom Data HandlerÀÇ DataHandler Ŭ·¡½º¿¡ ¹Ýµå½Ã ±¸ÇöÇØ¾ß Çϴ ǥ 75ÀÇ Ãß»ó ¸Þ¼Òµå¸¦ Á¦°øÇÕ´Ï´Ù.
Ç¥ 75. DataHandler Ŭ·¡½ºÀÇ Ãß»ó ¸Þ¼Òµå
µ¥ÀÌÅÍ º¯È¯ | Á÷·ÄÈµÈ µ¥ÀÌÅÍÀÇ Çü½Ä | DataHandler ¸Þ¼Òµå |
---|---|---|
¹®ÀÚ¿¿¡¼ Business Object·Î º¯È¯ | Reader ¿ÀºêÁ§Æ®¸¦ ÅëÇØ ¾×¼¼½ºµÇ´Â Á÷·ÄÈµÈ µ¥ÀÌÅ͸¦ Business Object·Î º¯È¯ÇÕ´Ï´Ù. | getBO() - Ãß»ó |
Business Object¿¡¼ ¹®ÀÚ¿·Î º¯È¯ | Business Object¸¦ InputStream ¿ÀºêÁ§Æ®·Î º¯È¯ÇÕ´Ï´Ù. | getStreamFromBO() |
| Business Object¸¦ String ¿ÀºêÁ§Æ®·Î º¯È¯ÇÕ´Ï´Ù. | getStringFromBO() |
| Business Object¸¦ ¹ÙÀÌÆ® ¹è¿·Î º¯È¯ÇÕ´Ï´Ù. | getByteArrayFromBO() |
´ÙÀ½ ¼½¼Ç¿¡¼´Â Ãß»ó DataHandler ¸Þ¼Òµå °¢°¢¿¡ ´ëÇÑ ±¸Çö Á¤º¸¸¦ Á¦°øÇÕ´Ï´Ù.
Ãß»ó getBO() ¸Þ¼Òµå´Â ¹®ÀÚ¿¿¡¼ Business Object·ÎÀÇ º¯È¯À» ¼öÇàÇÕ´Ï´Ù. Áï, Business Object¸¦ Java Reader ¿ÀºêÁ§Æ®¿¡¼ ÃßÃâÇÑ µ¥ÀÌÅͷΠä¿ó´Ï´Ù.
getBO() ¸Þ¼Òµå ¹öÀüÀº µÎ °¡ÁöÀÔ´Ï´Ù.
ÀÔ·Â Àμö¿¡´Â Á÷·ÄÈµÈ µ¥ÀÌÅÍ ¹× Business Object¿¡ ´ëÇÑ ÂüÁ¶°¡ µé¾î ÀÖ´Â Reader ¿ÀºêÁ§Æ®°¡ Æ÷ÇԵ˴ϴÙ. ¸Þ¼Òµå´Â theBusObj Business Object¸¦ serializedData µ¥ÀÌÅͷΠä¿ó´Ï´Ù.
ÀÔ·Â Àμö¿¡´Â Á÷·ÄÈµÈ µ¥ÀÌÅͰ¡ µé¾î ÀÖ´Â Reader ¿ÀºêÁ§Æ®°¡ Æ÷ÇԵ˴ϴÙ. ¸Þ¼Òµå´Â µ¥ÀÌÅÍ¿¡¼ Business Object À¯ÇüÀÇ À̸§(Business Object Á¤ÀÇ)À» ÆÇº°ÇÑ ÈÄ ÇØ´ç À¯ÇüÀÇ Business Object ÀνºÅϽº¸¦ ÀÛ¼ºÇÏ¿© ä¿ó´Ï´Ù.
getBO() ¸Þ¼Òµå´Â È£ÃâÀÚ°¡ ±¸¼º Á¤º¸(config ¸Å°³º¯¼ö)¸¦ Æ÷ÇÔÇÏ´Â ¼±ÅÃÀû ¿ÀºêÁ§Æ®¸¦ Àü´ÞÇÕ´Ï´Ù. ÀÌ Á¤º¸´Â Data Handler Meta Object¿¡¼ ÁöÁ¤µÈ Á¤º¸ ¿Ü¿¡ Ãß°¡µÇ´Â Á¤º¸ÀÔ´Ï´Ù. ¿¹¸¦ µé¾î, ±¸¼º ¿ÀºêÁ§Æ®´Â ÅÛÇø®Æ® ÆÄÀÏÀ̳ª, Data Handler°¡ »ç¿ëÇÏ´Â URLÀ» Áö½ÃÇÒ ¼ö ÀÖ½À´Ï´Ù.
cw_mo_label ű׿¡ ´ëÇÑ ÀÚ¼¼ÇÑ Á¤º¸´Â "Business Object¿¡¼ º¯È¯ ±¸Çö"À» ÂüÁ¶ÇϽʽÿÀ.
Ãß»ó getBO() ¸Þ¼ÒµåÀÇ ¸ñÀûÀº Reader ¿ÀºêÁ§Æ®¿¡ µé¾î ÀÖ´Â Á÷·ÄÈµÈ µ¥ÀÌÅÍ·Î Business Object¸¦ ä¿ì´Â °ÍÀÔ´Ï´Ù. ±×·¯¸é getBO()ÀÇ °ø¿ë ¹öÀüÀÌ Áö¿øµÇ´Â ¿©·¯ ¾ç½Ä Áß Çϳª·Î Á÷·ÄÈµÈ µ¥ÀÌÅ͸¦ ¼ö½ÅÇÏ°í µ¥ÀÌÅ͸¦ Reader ¿ÀºêÁ§Æ®·Î º¯È¯ÇÑ ÈÄ, Ãß»ó getBO() ¸Þ¼Òµå¸¦ È£ÃâÇÏ¿©, ½ÇÁ¦ ¹®ÀÚ¿¿¡¼ Business Object·ÎÀÇ º¯È¯À» ¼öÇàÇÒ ¼ö ÀÖ½À´Ï´Ù. °ø¿ë getBO() ¸Þ¼Òµå¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ Á¤º¸´Â getBO() - °ø¿ëÀ» ÂüÁ¶ÇϽʽÿÀ.
±×¸² 41¿¡¼´Â µÎ ¹øÂ° ¾ç½ÄÀÇ getBO() ¸Þ¼Òµå¿¡ ´ëÇÑ ±âº» ±¸ÇöÀ» º¸¿©ÁÝ´Ï´Ù. ¿¹¿¡¼´Â °íÁ¤ Æø µ¥ÀÌÅ͸¦ Æ÷ÇÔÇÏ´Â Reader ¿ÀºêÁ§Æ®ÀÇ µ¥ÀÌÅͰ¡ Business Object·Î º¯È¯ÇÒ ¶§ »ç¿ëµÇ´Â ´Ü°è¸¦ º¸¿©ÁÝ´Ï´Ù.
getBOFromString() ¸Þ¼Òµå´Â JavaConnectorUtil.createBusinessObject()¸¦ È£ÃâÇÏ¿© Business Object ÀνºÅϽº¸¦ ÀÛ¼ºÇϰí BusinessObjectInterface.setVerb()¸¦ È£ÃâÇÏ¿© verb¸¦ ¼³Á¤ÇÕ´Ï´Ù. Business Object ó¸® ¹æ¹ý¿¡ ´ëÇÑ Á¤º¸´Â Connector Development Guide for Java¸¦ ÂüÁ¶ÇϽʽÿÀ.
public BusinessObjectInterface getBO(Reader serializedData, Object config) throws Exception { clear(config); BusinessObjectInterface resultObj = null; // Create a String object from the Reader, then use the string // method int conversionCheck; char[] temp = new char[2000]; StringBuffer tempStringBuffer = new StringBuffer(1000); while ( (conversionCheck = serializedData.read(temp)) != -1 ) tempStringBuffer.append(new String (temp, 0, conversionCheck)); mBOString = new String(tempStringBuffer); mBOStringLength = mBOString.length(); resultObj = getBOFromString(null); return resultObj; } // Gets Business Object name and verb and creates a bus obj instance private BusinessObjectInterface getBOFromString(String pvBOType) throws Exception { BusinessObjectInterface returnObj = null; String lvBOName = null; String lvVerb = null; lvBOName = this.getNextToken(mBONameSize, true); lvVerb = this.getNextToken(mBOVerbSize, true); if( (pvBOType != null) && (lvBOName.compareTo(pvBOType) != 0) ) { throw new Exception(...); } else { returnObj = JavaConnectorUtil.createBusinessObject(lvBOName); } returnObj.setVerb(lvVerb); parseAttributeList(returnObj); return returnObj; }
// Parse String to populate the attributes in the Business Object protected void parseAttributeList(BusinessObjectInterface pvBO) throws Exception { if ( mEndOfBOString ) throw new Exception(...); else if( pvBO == null ) throw new Exception(...); int lvAttrNum = pvBO.getAttrCount(); String lvAttrName = null; String lvAttrValue = null; int lvAttrMaxLength = 0; try { for (int lvAttrIndex = 0; lvAttrIndex < lvAttrNum; lvAttrIndex++) { CxObjectAttr lvAttrSpec = pvBO.getAttrDesc(lvAttrIndex); lvAttrName = lvAttrSpec.getName(); // Determine if the attribute is a simple attribute or a // Business Object container. if (lvAttrSpec.isObjectType()) { // Get the next token based on the BOCountSize lvAttrMaxLength = mBOCountSize; lvAttrValue = this.getNextToken(mBOCountSize, true); String lvBOType = lvAttrSpec.getTypeName(); Object lvAttrBOValue = null; if (lvAttrSpec.isMultipleCard()) { this.getMultipleCard(pvBO,lvAttrIndex,lvBOType, lvAttrValue); } else { this.getSingleCard(pvBO,lvAttrIndex,lvBOType, lvAttrValue); } } else { // Get the next token based on the MaxLength of the attribute lvAttrMaxLength = lvAttrSpec.getMaxLength(); if (lvAttrMaxLength > 0) lvAttrValue = this.getNextToken(lvAttrMaxLength, false); else lvAttrValue = null;
// For simple String attribute, set to null, set to // configured CxIgnore or CxBlank values, or set to the // attribute value if (lvAttrValue == null ) pvBO.setAttrValue(lvAttrIndex, null); else if (lvAttrValue.equals(mCxIgnore)|| lvAttrValue.equals("")) pvBO.setAttrValue(lvAttrIndex, null); else if (lvAttrValue.equals(mCxBlank)|| lvAttrValue.equals(" ")) pvBO.setAttrValue(lvAttrIndex, ""); else pvBO.setAttrValue(lvAttrIndex, lvAttrValue); } } } } // Populates a child container with values in the String protected void getMultipleCard(BusinessObjectInterface pvParentBO, int pvParentAttrIndex, String pvBOType, String pvObjectCountString) throws CW_BOFormatException, Exception { try { if ( pvObjectCountString.equals(mCxIgnore) ) { // trace message } else { int lvObjectCount = Integer.parseInt(pvObjectCountString); if ( lvObjectCount == 0) { // trace message with the number of objects in container } else if (lvObjectCount > 0) { // There is at least one instance of the object in the string BusinessObjectInterface lvChildBO = null; // For each instance of the child object, parse the attribute // list, and then add the object container to the parent. for (int lvObjectIndex = 0; lvObjectIndex < lvObjectCount; lvObjectIndex++) { lvChildBO = getBOFromString(pvBOType); pvParentBO.setAttrValue(pvParentAttrIndex,lvChildBO); } } } } }
// Populates a single cardinality child with values in the String protected void getSingleCard(BusinessObjectInterface pvParentBO, int pvParentAttrIndex, String pvBOType, String pvObjectCountString) throws CW_BOFormatException, Exception { try { BusinessObjectInterface lvChildBO = null; // Check the object count token // If it does not match "1", assume that the child object should // be null if (pvObjectCountString.equals("1")) { // The string contains a single instance of the child lvChildBO = getBOFromString(pvBOType); pvParentBO.setAttrValue(pvParentAttrIndex, lvChildBO); } else if ( pvObjectCountString.equals(mCxIgnore) || pvObjectCountString.equals("0")) { // Validate that the object count token is valid } else throw new CW_BOFormatException(...); } }
Ç¥ 76ÀÇ Ãß»ó ¸Þ¼Òµå´Â Business Object¿¡¼ ¹®ÀÚ¿·ÎÀÇ º¯È¯À» ¼öÇàÇÕ´Ï´Ù. Áï, °¢°¢ Business ObjectÀÇ Æ¯Á¤ ¾ç½ÄÀ¸·Î Á÷·ÄÈµÈ µ¥ÀÌÅ͸¦ ÀÛ¼ºÇÕ´Ï´Ù.
Ç¥ 76. Business Object¿¡¼ ¹®ÀÚ¿·ÎÀÇ º¯È¯À» ±¸ÇöÇÏ´Â Ãß»ó ¸Þ¼Òµå
Ãß»ó ¸Þ¼Òµå | ¼³¸í |
---|---|
getStringFromBO() | Business ObjectÀÇ µ¥ÀÌÅ͸¦ String ¿ÀºêÁ§Æ®·Î º¯È¯ÇÕ´Ï´Ù. |
getStreamFromBO() | Business ObjectÀÇ µ¥ÀÌÅ͸¦ InputStream ¿ÀºêÁ§Æ®·Î º¯È¯ÇÕ´Ï´Ù. |
getByteArrayFromBO() | Business ObjectÀÇ µ¥ÀÌÅ͸¦ ¹ÙÀÌÆ® ¹è¿·Î º¯È¯ÇÕ´Ï´Ù. |
Business Object·ÎºÎÅÍÀÇ º¯È¯ ¸ñÀûÀº Business Object¿¡ ÀÖ´Â ¸ðµç µ¥ÀÌÅÍÀÇ Á÷·ÄÈµÈ ¾ç½ÄÀ» ÀÛ¼ºÇÏ´Â °ÍÀÔ´Ï´Ù. ±×·¯³ª ¶§¶§·Î ÀϺΠBusiness Object µ¥ÀÌÅÍ´Â Á÷·ÄÈµÈ µ¥ÀÌÅÍ¿¡ Æ÷ÇÔµÇÁö ¸»¾Æ¾ß ÇÕ´Ï´Ù. ¿¹¸¦ µé¾î, Business Object´Â ÇÏÀ§ Meta Object¸¦ »ç¿ëÇÏ¿© Ä¿³ØÅÍ¿¡ ´ëÇÑ µ¿Àû ±¸¼º Á¤º¸¸¦ º¸À¯ÇÒ ¼ö ÀÖ½À´Ï´Ù.
IBMÀº ±¸¼º ¹×/¶Ç´Â µ¿Àû ¸ÞŸ µ¥ÀÌÅ͸¦ À§ÇØ cw_mo_label Á¢µÎºÎ·Î ½ÃÀÛÇÏ´Â ¸ðµç ÀÀ¿ëÇÁ·Î±×·¥ ƯÁ¤ Á¤º¸¸¦ ¿¹¾àÇÕ´Ï´Ù.
Data Handler°¡ Business Object·ÎºÎÅÍÀÇ º¯È¯ Áß¿¡ ¹«½ÃÇØ¾ß ÇÏ´Â ¼Ó¼ºÀ» Ç¥½ÃÇϱâ À§ÇØ, »óÀ§ Business Object¿¡ ´ëÇÑ Business Object Á¤ÀÇ´Â ÀÀ¿ëÇÁ·Î±×·¥ ƯÁ¤ Á¤º¸¿¡ ´ÙÀ½ ű׸¦ ÁöÁ¤ÇÕ´Ï´Ù.
cw_mo_label=child_meta-object_attribute_name
¿©±â¼ labelÀº Ãß°¡·Î cw_mo_ ű×ÀÇ ¸ñÀûÀ» ´õ ½Äº°Çϱâ À§ÇØ Á¤ÀÇÇÏ´Â ¹®ÀÚ¿À̰í child_meta-object_attribute_nameÀº ¹«½ÃÇÒ ¼Ó¼ºÀÇ À̸§À» ½Äº°ÇÕ´Ï´Ù. ÀÌ ¼Ó¼º¿¡´Â º¸Åë ÇÏÀ§ Meta Object°¡ Æ÷ÇԵ˴ϴÙ. ¿©·¯ cw_mo_label ű״ ¼¼¹ÌÄÝ·Ð(;)À¸·Î ±¸ºÐµË´Ï´Ù.
Custom Data Handler¿¡ ´ëÇØ getStringFromBO(), getStreamFromBO() ¹× getByteArrayFromBO() ¸Þ¼Òµå¸¦ ±¸ÇöÇÏ´Â °æ¿ì, ÀÌ ¸Þ¼Òµå´Â ´ÙÀ½°ú °°ÀÌ Data Handler°¡ Ä¿³ØÅÍ Æ¯Á¤ ¼Ó¼ºÀ» °Ç³Ê¶Ùµµ·Ï ÇØ¾ß ÇÕ´Ï´Ù.
object_attribute_name)À» ãÀ¸½Ê½Ã¿À. µîÈ£(=) ¾ÕµÚÀÇ ¸ðµç °ø¹éÀº ¹«½ÃÇϽʽÿÀ.
object_attribute_name ¹®ÀÚ¿°ú ºñ±³ÇϽʽÿÀ. ÀÌ À̸§ÀÇ ¼Ó¼ºÀ» °Ç³Ê¶Ù½Ê½Ã¿À.
´ÙÀ½ ÄÚµå ´ÜÆí¿¡¼´Â ¼Ó¼ºÀ» °Ç³Ê¶Ù´Â ¹æ¹ýÀ» º¸¿©ÁÝ´Ï´Ù.
List configObjList = com.crossworlds.DataHandlers.text.namevalue.listMOAttrNames(BusObj); //this list contains attribute names, which are configuration objects for ( attributes in BusObj ) { String attrName = BusObj.getAttrDisc(i).getName(); if ( configObjList.contains(attrName) ) { //skip continue; } }
¿¹¸¦ µé¾î, MyCustomer¶ó°í ÇÏ´Â Business Object°¡ ÇÏÀ§ Meta Object¸¦ »ç¿ëÇÏ¿© Ä¿³ØÅÍ Æ¯Á¤ ¶ó¿ìÆÃ Á¤º¸¸¦ º¸À¯ÇÑ´Ù°í °¡Á¤ÇÕ´Ï´Ù. ÀÌ Meta Object¸¦ ¼Ó¼º CustConfig·Î Ç¥½ÃÇÒ °æ¿ì, MyCustomer´Â ÀÀ¿ëÇÁ·Î±×·¥ ƯÁ¤ Á¤º¸¿¡ ´ÙÀ½ ű׸¦ °¡Áú ¼ö ÀÖ½À´Ï´Ù.
cw_mo_cfg=CustConfig
Business Object·ÎºÎÅÍ º¯È¯ Áß, Custom Data Handler´Â MyCustomer¿Í ¿¬°üµÈ Business Object Á¤ÀǸ¦ À§ÇØ ÀÀ¿ëÇÁ·Î±×·¥ ƯÁ¤ Á¤º¸¸¦ È®ÀÎÇϰí cw_mo_cfg ű׸¦ ãÀº ÈÄ, CustConfig ¼Ó¼ºÀ» °Ç³Ê¶Ù¾î¾ß ÇÏ´ÂÁö¸¦ ÆÇº°ÇÕ´Ï´Ù. ÀÌ¿¡ µû¶ó Data Handler¿¡¼ »ý¼ºµÇ´Â Á÷·ÄÈµÈ µ¥ÀÌÅÍ¿¡´Â CustConfig ÇÏÀ§ Meta Object°¡ Æ÷ÇÔµÇÁö ¾Ê½À´Ï´Ù.
Data Handler°¡ ÇÏÀ§ Meta Object³ª ´Ù¸¥ µ¿Àû ¿ÀºêÁ§Æ®¸¦ »ç¿ëÇÏ´Â Ä¿³ØÅÍ¿Í ÇÔ²² ÀÛµ¿ÇÒ °æ¿ì¿¡¸¸ cw_mo_label ű׸¦ ó¸®Çϱâ À§ÇÑ Custom Data Handler¸¦ °³¹ßÇØ¾ß ÇÕ´Ï´Ù.
getStringFromBO() ¸Þ¼Òµå´Â Business Object¿¡¼ ¹®ÀÚ¿·ÎÀÇ º¯È¯À» ¼öÇàÇÕ´Ï´Ù. Áï, Business ObjectÀÇ µ¥ÀÌÅ͸¦ String ¿ÀºêÁ§Æ®·Î º¯È¯ÇÕ´Ï´Ù. ÀÌ ¸Þ¼ÒµåÀÇ °æ¿ì, È£ÃâÀÚ´Â º¯È¯ÇÒ Business Object¸¦ Àü´ÞÇÕ´Ï´Ù. ±×¸² 42¿¡¼´Â FixedWidth Data Handler¿¡ ÀÇÇØ ±¸ÇöµÇ´Â getStringFromBO() ¸Þ¼Òµå¸¦ º¸¿©ÁÝ´Ï´Ù. ¸Þ¼Òµå´Â °íÁ¤ Æø ÇʵåÀÇ StringÀ» ÀÛ¼ºÇÕ´Ï´Ù.
´ÙÀ½ ¿¹¿¡¼´Â Business Object¿¡¼ Reader ¿ÀºêÁ§Æ®·Î µ¥ÀÌÅ͸¦ º¯È¯ÇÒ ¶§ »ç¿ëµÇ´Â ´Ü°è¸¦ º¸¿©ÁÝ´Ï´Ù.
±×¸² 42. getStringFromBO() ¸Þ¼Òµå ¿¹
public String getStringFromBO(BusinessObjectInterface theObj, Object config) throws Exception { traceWrite( "Entering getStringFromBO(BusinessObjectInterface, Object) " + " for object type " + theObj.getName(), JavaConnectorUtil.LEVEL4); clear(config); String lvBOString = null; setAttrList(theObj); lvBOString = mBOStringBuffer.toString(); traceWrite( "Exiting getStringFromBO(BusinessObjectInterface, Object) " + " for object type " + theObj.getName(), JavaConnectorUtil.LEVEL4); return lvBOString; } protected void setAttrList(BusinessObjectInterface pvBO) throws Exception { traceWrite( "Entering setAttrList(BusinessObjectInterface) for object " + pvBO.getName(), JavaConnectorUtil.LEVEL4); int lvAttrNum = pvBO.getAttrCount(); String lvAttrName = null; String lvAttrValue = null; int lvAttrMaxLength = 0; // Add the Business Object name and verb to the fixed width format // String this.setSimpleToken( mBONameSize, pvBO.getName()); this.setSimpleToken( mBOVerbSize, pvBO.getVerb()); try { List moAttrNames = listMOAttrNames( pvBO ); int lvAttrCount = pvBO.getAttrCount(); ATTRIBUTE_WALK: for (int lvAttrIndex = 0; lvAttrIndex < lvAttrCount; ++lvAttrIndex) { CxObjectAttr lvAttrSpec = pvBO.getAttrDesc(lvAttrIndex); lvAttrName = lvAttrSpec.getName(); // Check if the current attribute is a simple (String) type // or a contained object. if (lvAttrSpec.isObjectType()) { //skip child objects designated as meta objects if( moAttrNames.contains( lvAttrName ) ) { continue ATTRIBUTE_WALK; }
if (lvAttrSpec.isMultipleCard()) { CxObjectContainerInterface lvAttrMultiCardBOValue = (CxObjectContainerInterface) pvBO.getAttrValue(lvAttrIndex); if (lvAttrMultiCardBOValue == null) { traceWrite( "setAttrList found empty multiple cardinality container " + lvAttrSpec.getTypeName(), JavaConnectorUtil.LEVEL5); // Add the count to the fixed width String this.setSimpleToken( mBOCountSize, "0"); } else { int lvObjectCount = lvAttrMultiCardBOValue.getObjectCount(); traceWrite( "setAttrList found multiple cardinality container " + lvAttrSpec.getTypeName() + " with " + lvObjectCount + " instances", JavaConnectorUtil.LEVEL5); // Add the count to the fixed width String this.setSimpleToken( mBOCountSize, Integer.toString(lvObjectCount)); // Add each object in the container to the fixed // width String. for (int lvContObjectIndex = 0; lvContObjectIndex < lvObjectCount; ++lvContObjectIndex) setAttrList( lvAttrMultiCardBOValue.getBusinessObject(lvContObjectIndex)); } } else { BusinessObjectInterface lvAttrSingleCardBOValue = (BusinessObjectInterface) pvBO.getAttrValue(lvAttrIndex); if (lvAttrSingleCardBOValue == null) { traceWrite( "setAttrList found empty single cardinality container " + lvAttrSpec.getTypeName(), JavaConnectorUtil.LEVEL5); // Add the count to the fixed width String this.setSimpleToken( mBOCountSize, "0"); }
else { traceWrite( "setAttrList found single cardinality container " + lvAttrSpec.getTypeName(), JavaConnectorUtil.LEVEL5); // Add the count to the fixed width String this.setSimpleToken( mBOCountSize, "1"); setAttrList(lvAttrSingleCardBOValue); } } } else { lvAttrValue = (String) pvBO.getAttrValue(lvAttrIndex); lvAttrMaxLength = lvAttrSpec.getMaxLength(); if (lvAttrMaxLength > 0) this.setSimpleToken(lvAttrMaxLength, lvAttrValue); } } } catch (CxObjectNoSuchAttributeException e) { throw new Exception(e.getMessage()); } traceWrite( "Exiting setAttrList(BusinessObjectInterface) for object " + pvBO.getName(), JavaConnectorUtil.LEVEL4); } protected void setSimpleToken( int pvCellSize, String pvTokenValue) throws Exception { traceWrite( "Entering setSimpleToken(int, String)", JavaConnectorUtil.LEVEL4); StringBuffer lvNewBuffer = new StringBuffer(pvCellSize); int lvTokenLength = 0; int lvCxIgnoreLength = mCxIgnore.length(); int lvCxBlankLength = mCxBlank.length(); int lvPadNumber = 0; // Check the token value to see if it is null if (pvTokenValue == null) { // For this case, we add the configured CxIgnore value to the // fixed width String if it fits in the cell. if (!mTruncation && lvCxIgnoreLength > pvCellSize) throw new Exception( " Null attribute value encountered where cell size is " + pvCellSize + ", size of CxIgnore value is " + lvCxIgnoreLength + "and trucation is not allowed. " + "Please check your MO format configuration.");
else { lvPadNumber = pvCellSize - lvCxIgnoreLength; lvNewBuffer.append(mCxIgnore); } } else if (pvTokenValue.equals("")) { // For this case, the configured CxBlank value is added to the // fixed width String if it fits in the cell. if (! mTruncation && lvCxBlankLength > pvCellSize) throw new Exception( " Blank attribute value encountered where cell size is " + pvCellSize + ", size of CxBlank value is " + lvCxBlankLength + "and trucation is not allowed. " + "Please check your MO format configuration."); else { lvPadNumber = pvCellSize - lvCxBlankLength; lvNewBuffer.append(mCxBlank); } } else { // For this case, actually add the token value to the fixed // width String, unless the data is too long for the cell. lvTokenLength = pvTokenValue.length(); if (!mTruncation && lvTokenLength > pvCellSize ) throw new Exception( " Attribute value encountered where cell size is " + pvCellSize + ", size of token value is " + lvTokenLength + "and trucation is not allowed. " + "Please check your MO format configuration."); else { lvNewBuffer.append(pvTokenValue); lvPadNumber = pvCellSize - lvTokenLength; } } if (lvPadNumber <= 0 && mTruncation) // Token is longer than the cell and truncation is allowed, // so the characters up to pvCellSize are added lvNewBuffer.setLength(pvCellSize); else if (lvPadNumber > 0) { // Pad the cell based on the configuration option chosen if ( mAlignment.equals(fixedwidth.AlignmentLeft) || mAlignment.equals(fixedwidth.AlignmentBoth)) this.padRight(lvNewBuffer, lvPadNumber); else if (mAlignment.equals(fixedwidth.AlignmentRight)) this.padLeft(lvNewBuffer, lvPadNumber); }
String lvNewBuffString = lvNewBuffer.toString(); // Note that this may cause a performance issue when the tracing // level is low, but in most cases it should not as any one token // is *usually* not very long. traceWrite( "Adding the following token to the fixed width String: " + lvNewBuffString, JavaConnectorUtil.LEVEL5); // After the cell has been fully formatted, append to fixed width // String being built mBOStringBuffer.append(lvNewBuffString); traceWrite( "Exiting setSimpleToken(int, String)", JavaConnectorUtil.LEVEL4); }
getStreamFromBO() ¸Þ¼Òµå´Â Business ObjectÀÇ µ¥ÀÌÅ͸¦ InputStream ¿ÀºêÁ§Æ®·Î º¯È¯½Ãŵ´Ï´Ù.
±×¸² 43¿¡¼´Â
getStreamFromBO() ¸Þ¼Òµå¸¦ ±¸ÇöÇÑ ¿¹¸¦ º¸¿©ÁÝ´Ï´Ù. ÀÌ ±¸Çö¿¡¼,
getStreamFromBO()´Â getStringFromBO()¸¦ È£ÃâÇÏ¿© Business Object µ¥ÀÌÅ͸¦ Æ÷ÇÔÇÏ´Â String ¿ÀºêÁ§Æ®¸¦ ºôµåÇÑ ÈÄ StringÀ» InputStreamÀ¸·Î º¯È¯ÇÕ´Ï´Ù. ¸Þ¼Òµå´Â Business ObjectÀÇ µ¥ÀÌÅ͸¦ Ç¥½ÃÇÏ´Â InputStream ¿ÀºêÁ§Æ®¸¦ ¸®ÅÏÇÕ´Ï´Ù.
±×¸² 43. getStreamFromBO() ¸Þ¼Òµå ¿¹
public InputStream getStreamFromBO(BusinessObjectInterface theObj, Object config) throws Exception { clear(config); String BOstring; BOstring = getStringFromBO(theObj, config); return new ByteArrayInputStream( BOstring.getBytes() ); }
Ãß»ó DataHandler ¸Þ¼Òµå(±¸ÇöÇØ¾ß ÇÏ´Â ¸Þ¼Òµå) ¿Ü¿¡µµ,
Custom Data Handler¿¡ ´ëÇØ ÃÖÀûÀ¸·Î ÀÛµ¿Çϵµ·Ï DataHandler Ŭ·¡½ºÀÇ
°ø¿ë ¸Þ¼Òµå¸¦ ´ëÃ¼ÇØ¾ß ÇÏ´Â °æ¿ìµµ ÀÖ½À´Ï´Ù(Ç¥ 77 ÂüÁ¶).
Ç¥ 77. DataHandler Ŭ·¡½ºÀÇ °ø¿ë ¸Þ¼Òµå
°ø¿ë DataHandler ¸Þ¼Òµå | ¼³¸í |
---|---|
getBO() - °ø¿ë | Á÷·ÄÈµÈ µ¥ÀÌÅÍ(¸î °¡Áö Çü½Ä Áß Çϳª)¸¦ Business Object·Î º¯È¯ÇÕ´Ï´Ù. |
getBOName() | Á÷·ÄÈµÈ µ¥ÀÌÅÍ¿¡¼ Business ObjectÀÇ À̸§À» È®º¸ÇÕ´Ï´Ù. |
getBooleanOption() | Data Handler¿¡¼ ºÎ¿ï ±¸¼º ¿É¼ÇÀÇ °ªÀ» È®º¸ÇÕ´Ï´Ù. |
getOption() | Data Handler¿¡¼ ±¸¼º ¿É¼ÇÀÇ °ªÀ» È®º¸ÇÕ´Ï´Ù. |
setOption() | Data Handler¿¡¼ ±¸¼º ¿É¼ÇÀ» ¼³Á¤ÇÕ´Ï´Ù. |
traceWrite() | Data Handler(Ä¿³ØÅÍ ¶Ç´Â ÅëÇÕ ºê·ÎÄ¿°¡ InterChange ServerÀÎ °æ¿ì ¼¹ö ¾×¼¼½º ÀÎÅÍÆäÀ̽º)ÀÇ ÇØ´ç ¹®¸Æ¿¡ ´ëÇØ trace-write ¸Þ¼Òµå¸¦ È£ÃâÇÕ´Ï´Ù. |